Skip to content

Commit

Permalink
Merge pull request #120 from nolaviz/sep-incompatible-improvements
Browse files Browse the repository at this point in the history
Re-enable bare `<sep>` when incompatibleImprovements < 2.3.34.
  • Loading branch information
ddekany authored Dec 8, 2024
2 parents aba94c0 + de37405 commit 69cf616
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion freemarker-core/src/main/javacc/freemarker/core/FTL.jj
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,9 @@ TOKEN:
|
<ITEMS : <START_TAG> "items" (<BLANK>)+ <AS> <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
<SEP : <START_TAG> "sep" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
<SEP : <START_TAG> "sep" <CLOSE_TAG1>> {
if (incompatibleImprovements >= _VersionInts.V_2_3_24) handleTagSyntaxAndSwitch(matchedToken, DEFAULT);
}
|
<FOREACH : <START_TAG> "for" ("e" | "E") "ach" <BLANK>> {
handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), FM_EXPRESSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class SepParsingBugTest extends TemplateTest {

@Test
public void testAutodetectTagSyntax() throws TemplateException, IOException {
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24);
getConfiguration().setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX);
assertOutput("<#list [1, 2] as i>${i}<#sep>, </#list>", "1, 2");
assertOutput("[#list [1, 2] as i]${i}[#sep], [/#list]", "1, 2");
Expand All @@ -42,6 +43,7 @@ public void testAutodetectTagSyntax() throws TemplateException, IOException {

@Test
public void testAngleBracketsTagSyntax() throws TemplateException, IOException {
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24);
getConfiguration().setTagSyntax(Configuration.ANGLE_BRACKET_TAG_SYNTAX);
assertOutput("<#list [1, 2] as i>${i}<#sep>, </#list>", "1, 2");
assertOutput("[#list [1, 2] as i]${i!'-'}[#sep], [/#list]", "[#list [1, 2] as i]-[#sep], [/#list]");
Expand All @@ -53,6 +55,7 @@ public void testAngleBracketsTagSyntax() throws TemplateException, IOException {

@Test
public void testSquareBracketTagSyntax() throws TemplateException, IOException {
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24);
getConfiguration().setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
assertOutput("<#list [1, 2] as i>${i!'-'}<#sep>, </#list>", "<#list [1, 2] as i>-<#sep>, </#list>");
assertOutput("[#list [1, 2] as i]${i}[#sep], [/#list]", "1, 2");
Expand All @@ -62,4 +65,10 @@ public void testSquareBracketTagSyntax() throws TemplateException, IOException {
assertErrorContains("[#sep]", "#sep must be inside");
}

@Test
public void testLegacyTagSyntax() throws TemplateException, IOException {
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_23);
getConfiguration().setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX);
assertOutput("<#list [1, 2] as i>${i}<sep>, </#list>", "1, 2");
}
}

0 comments on commit 69cf616

Please sign in to comment.