Skip to content

Commit 69cf616

Browse files
authored
Merge pull request #120 from nolaviz/sep-incompatible-improvements
Re-enable bare `<sep>` when incompatibleImprovements < 2.3.34.
2 parents aba94c0 + de37405 commit 69cf616

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

freemarker-core/src/main/javacc/freemarker/core/FTL.jj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,9 @@ TOKEN:
943943
|
944944
<ITEMS : <START_TAG> "items" (<BLANK>)+ <AS> <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
945945
|
946-
<SEP : <START_TAG> "sep" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
946+
<SEP : <START_TAG> "sep" <CLOSE_TAG1>> {
947+
if (incompatibleImprovements >= _VersionInts.V_2_3_24) handleTagSyntaxAndSwitch(matchedToken, DEFAULT);
948+
}
947949
|
948950
<FOREACH : <START_TAG> "for" ("e" | "E") "ach" <BLANK>> {
949951
handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), FM_EXPRESSION);

freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class SepParsingBugTest extends TemplateTest {
3131

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

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

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

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

0 commit comments

Comments
 (0)