diff --git a/src/main/java/com/hubspot/jinjava/tree/parse/TagToken.java b/src/main/java/com/hubspot/jinjava/tree/parse/TagToken.java index d73c33b22..14a11ff49 100644 --- a/src/main/java/com/hubspot/jinjava/tree/parse/TagToken.java +++ b/src/main/java/com/hubspot/jinjava/tree/parse/TagToken.java @@ -44,6 +44,13 @@ public int getType() { @Override protected void parse() { if (image.length() < 4) { + if (image.equals("{%}")) { + tagName = ""; + rawTagName = ""; + helpers = ""; + content = ""; + return; + } throw new TemplateSyntaxException( image, "Malformed tag token", diff --git a/src/test/java/com/hubspot/jinjava/tree/parse/TagTokenTest.java b/src/test/java/com/hubspot/jinjava/tree/parse/TagTokenTest.java index 83bd6b96d..5bc0b8962 100644 --- a/src/test/java/com/hubspot/jinjava/tree/parse/TagTokenTest.java +++ b/src/test/java/com/hubspot/jinjava/tree/parse/TagTokenTest.java @@ -38,4 +38,11 @@ public void itThrowsParseErrorWhenMalformed() { assertThat(e).hasMessageContaining("Malformed"); } } + + @Test + public void testParseEmptyTagWithHelpers() { + TagToken t = new TagToken("{%}", 1, 2, SYMBOLS); + assertThat(t.getTagName()).isEqualTo(""); + assertThat(t.getHelpers().trim()).isEqualTo(""); + } }