Removed long deprecated <#foreach ...>...</#foreach> directive.
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/e3486d9e Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/e3486d9e Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/e3486d9e Branch: refs/heads/3 Commit: e3486d9e69cdc862c0f4232599925f3436f53993 Parents: 9cab8d1 Author: ddekany <[email protected]> Authored: Fri Mar 3 22:21:25 2017 +0100 Committer: ddekany <[email protected]> Committed: Fri Mar 3 22:21:25 2017 +0100 ---------------------------------------------------------------------- .../org/apache/freemarker/core/ASTDirList.java | 31 +++------ .../apache/freemarker/core/ParseException.java | 3 - src/main/javacc/FTL.jj | 73 +++----------------- src/manual/en_US/FM3-CHANGE-LOG.txt | 3 +- .../freemarker/core/BreakPlacementTest.java | 1 - .../apache/freemarker/core/CamelCaseTest.java | 37 +--------- .../apache/freemarker/core/ListErrorsTest.java | 14 ++-- .../templatesuite/templates/comparisons.ftl | 4 +- .../test/templatesuite/templates/interpret.ftl | 2 +- .../test/templatesuite/templates/iterators.ftl | 16 ++--- .../templatesuite/templates/listliteral.ftl | 24 +++---- .../templatesuite/templates/multimodels.ftl | 4 +- .../test/templatesuite/templates/nested.ftl | 4 +- .../templates/string-builtins1.ftl | 4 +- .../test/templatesuite/templates/switch.ftl | 4 +- .../templatesuite/templates/type-builtins.ftl | 6 +- .../test/templatesuite/templates/xml.ftl | 12 ++-- 17 files changed, 67 insertions(+), 175 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/main/java/org/apache/freemarker/core/ASTDirList.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ASTDirList.java b/src/main/java/org/apache/freemarker/core/ASTDirList.java index 5ed1d39..0675882 100644 --- a/src/main/java/org/apache/freemarker/core/ASTDirList.java +++ b/src/main/java/org/apache/freemarker/core/ASTDirList.java @@ -38,7 +38,7 @@ import org.apache.freemarker.core.model.impl.SimpleNumber; import org.apache.freemarker.core.util._StringUtil; /** - * AST directive node: {@code #list} (or {@code #foreach}) element, or pre-{@code #else} section of it inside a + * AST directive node: {@code #list} element, or pre-{@code #else} section of it inside a * {@link ASTDirListElseContainer}. */ final class ASTDirList extends ASTDirective { @@ -47,7 +47,6 @@ final class ASTDirList extends ASTDirective { private final String loopVarName; private final String loopVar2Name; private final boolean hashListing; - private final boolean forEach; /** * @param listedExp @@ -66,21 +65,17 @@ final class ASTDirList extends ASTDirective { * @param hashListing * Whether this is a key-value pair listing, or a usual listing. This is properly set even if we have * a nested {@code #items}. - * @param forEach - * Whether this is {@code #foreach} or a {@code #list}. */ ASTDirList(ASTExpression listedExp, String loopVarName, String loopVar2Name, TemplateElements childrenBeforeElse, - boolean hashListing, - boolean forEach) { + boolean hashListing) { this.listedExp = listedExp; this.loopVarName = loopVarName; this.loopVar2Name = loopVar2Name; setChildren(childrenBeforeElse); this.hashListing = hashListing; - this.forEach = forEach; } boolean isHashListing() { @@ -132,19 +127,13 @@ final class ASTDirList extends ASTDirective { if (canonical) buf.append('<'); buf.append(getNodeTypeSymbol()); buf.append(' '); - if (forEach) { + buf.append(listedExp.getCanonicalForm()); + if (loopVarName != null) { + buf.append(" as "); buf.append(_StringUtil.toFTLTopLevelIdentifierReference(loopVarName)); - buf.append(" in "); - buf.append(listedExp.getCanonicalForm()); - } else { - buf.append(listedExp.getCanonicalForm()); - if (loopVarName != null) { - buf.append(" as "); - buf.append(_StringUtil.toFTLTopLevelIdentifierReference(loopVarName)); - if (loopVar2Name != null) { - buf.append(", "); - buf.append(_StringUtil.toFTLTopLevelIdentifierReference(loopVar2Name)); - } + if (loopVar2Name != null) { + buf.append(", "); + buf.append(_StringUtil.toFTLTopLevelIdentifierReference(loopVar2Name)); } } if (canonical) { @@ -196,7 +185,7 @@ final class ASTDirList extends ASTDirective { @Override String getNodeTypeSymbol() { - return forEach ? "#foreach" : "#list"; + return "#list"; } @Override @@ -205,7 +194,7 @@ final class ASTDirList extends ASTDirective { } /** - * Holds the context of a #list (or #forEach) directive. + * Holds the context of a #list directive. */ class IterationContext implements LocalContext { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/main/java/org/apache/freemarker/core/ParseException.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/freemarker/core/ParseException.java b/src/main/java/org/apache/freemarker/core/ParseException.java index dcb0f46..ef4d0e8 100644 --- a/src/main/java/org/apache/freemarker/core/ParseException.java +++ b/src/main/java/org/apache/freemarker/core/ParseException.java @@ -377,9 +377,6 @@ public class ParseException extends IOException implements FMParserConstants { for (int[] sequence : expectedTokenSequences) { for (int aSequence : sequence) { switch (aSequence) { - case END_FOREACH: - endNames.add("#foreach"); - break; case END_LIST: endNames.add("#list"); break; http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/main/javacc/FTL.jj ---------------------------------------------------------------------- diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj index 29a08c4..fd3f429 100644 --- a/src/main/javacc/FTL.jj +++ b/src/main/javacc/FTL.jj @@ -44,9 +44,8 @@ import java.util.*; public class FMParser { private static final int ITERATOR_BLOCK_KIND_LIST = 0; - private static final int ITERATOR_BLOCK_KIND_FOREACH = 1; - private static final int ITERATOR_BLOCK_KIND_ITEMS = 2; - private static final int ITERATOR_BLOCK_KIND_USER_DIRECTIVE = 3; + private static final int ITERATOR_BLOCK_KIND_ITEMS = 1; + private static final int ITERATOR_BLOCK_KIND_USER_DIRECTIVE = 2; private static class ParserIteratorBlockContext { /** @@ -82,19 +81,14 @@ public class FMParser { private ParserConfiguration pCfg; private InputStream streamToUnmarkWhenEncEstabd; - /** Keeps track of #list and #foreach nesting. */ + /** Keeps track of #list nesting. */ private List/*<ParserIteratorBlockContext>*/ iteratorBlockContexts; /** * Keeps track of the nesting depth of directives that support #break. */ private int breakableDirectiveNesting; - - /** - * Keeps track of the flags of the innermost parent #list or #foreach directive. - */ - private int parentListAndForeachFlags; - + private boolean inMacro, inFunction; private LinkedList escapes = new LinkedList(); private int mixedContentNesting; // for stripText @@ -438,12 +432,7 @@ public class FMParser { + "but there's no loop variable in scope with this name: " + loopVarName, lhoExp); } - - private String forEachDirectiveSymbol() { - // [2.4] Use camel case as the default - return token_source.namingConvention == Configuration.CAMEL_CASE_NAMING_CONVENTION ? "#forEach" : "#foreach"; - } - + } PARSER_END(FMParser) @@ -766,10 +755,6 @@ TOKEN: | <SEP : <START_TAG> "sep" <CLOSE_TAG1>> | - <FOREACH : <START_TAG> "for" ("e" | "E") "ach" <BLANK>> { - handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), FM_EXPRESSION); - } - | <SWITCH : <START_TAG> "switch" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); } | <CASE : <START_TAG> "case" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); } @@ -830,10 +815,6 @@ TOKEN: | <END_ATTEMPT : <END_TAG> "attempt" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); } | - <END_FOREACH : <END_TAG> "for" ("e" | "E") "ach" <CLOSE_TAG1>> { - handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), DEFAULT); - } - | <END_LOCAL : <END_TAG> "local" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); } | <END_GLOBAL : <END_TAG> "global" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); } @@ -2452,7 +2433,7 @@ ASTElement List() : exp, loopVar != null ? loopVar.image : null, // null when we have a nested #items loopVar2 != null ? loopVar2.image : null, - childrendBeforeElse, iterCtx.hashListing, false); + childrendBeforeElse, iterCtx.hashListing); list.setLocation(template, start, end); ASTElement result; @@ -2481,38 +2462,6 @@ ASTDirElseOfList ASTDirElseOfList() : } } -ASTDirList ForEach() : -{ - ASTExpression exp; - Token loopVar, start, end; - TemplateElements children; -} -{ - start = <FOREACH> - loopVar = <ID> - <IN> - exp = ASTExpression() - <DIRECTIVE_END> - { - ParserIteratorBlockContext iterCtx = pushIteratorBlockContext(); - iterCtx.loopVarName = loopVar.image; - iterCtx.kind = ITERATOR_BLOCK_KIND_FOREACH; - breakableDirectiveNesting++; - } - - children = MixedContentElements() - - end = <END_FOREACH> - { - breakableDirectiveNesting--; - popIteratorBlockContext(); - - ASTDirList result = new ASTDirList(exp, loopVar.image, null, children, false, true); - result.setLocation(template, start, end); - return result; - } -} - ASTDirItems Items() : { Token loopVar, loopVar2 = null, start, end; @@ -2534,9 +2483,7 @@ ASTDirItems Items() : } if (iterCtx.loopVarName != null) { String msg; - if (iterCtx.kind == ITERATOR_BLOCK_KIND_FOREACH) { - msg = forEachDirectiveSymbol() + " doesn't support nested #items."; - } else if (iterCtx.kind == ITERATOR_BLOCK_KIND_ITEMS) { + if (iterCtx.kind == ITERATOR_BLOCK_KIND_ITEMS) { msg = "Can't nest #items into each other when they belong to the same #list."; } else { msg = "The parent #list of the #items must not have \"as loopVar\" parameter."; @@ -2582,7 +2529,7 @@ ASTDirSep Sep() : { if (peekIteratorBlockContext() == null) { throw new ParseException( - "#sep must be inside a #list (or " + forEachDirectiveSymbol() + ") block.", + "#sep must be inside a #list block.", template, start); } } @@ -2679,7 +2626,7 @@ ASTDirBreak Break() : { if (breakableDirectiveNesting < 1) { throw new ParseException(start.image + " must be nested inside a directive that supports it: " - + " #list with \"as\", #items, #switch (or the deprecated " + forEachDirectiveSymbol() + ")", + + " #list with \"as\", #items, #switch", template, start); } ASTDirBreak result = new ASTDirBreak(); @@ -3654,8 +3601,6 @@ ASTElement FreemarkerDirective() : | tp = List() | - tp = ForEach() - | tp = Assign() | tp = Include() http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/manual/en_US/FM3-CHANGE-LOG.txt ---------------------------------------------------------------------- diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt index e2814ab..8a2dd81 100644 --- a/src/manual/en_US/FM3-CHANGE-LOG.txt +++ b/src/manual/en_US/FM3-CHANGE-LOG.txt @@ -142,4 +142,5 @@ the FreeMarer 3 changelog here: - Removed some long deprecated template language directives: - <#call ...> (deprecated by <@... />) - <#comment>...</#comment> (deprecated by <#-- ... -->) - - <#transform ...>...</#transform> (deprecated by <@...>...</@...>) \ No newline at end of file + - <#transform ...>...</#transform> (deprecated by <@...>...</@...>) + - <#foreach x in xs>...</#foreach> (deprecated by <#list xs as x>...</#list>) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/java/org/apache/freemarker/core/BreakPlacementTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/BreakPlacementTest.java b/src/test/java/org/apache/freemarker/core/BreakPlacementTest.java index 44f99fb..05da5bc 100644 --- a/src/test/java/org/apache/freemarker/core/BreakPlacementTest.java +++ b/src/test/java/org/apache/freemarker/core/BreakPlacementTest.java @@ -41,7 +41,6 @@ public class BreakPlacementTest extends TemplateTest { + "<#list xs>[<#items as x>${x}</#items>]<#else><#break></#list>" + "</#list>.", "[12][34]."); - assertOutput("<#forEach x in 1..2>${x}<#break></#forEach>", "1"); } @Test http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/java/org/apache/freemarker/core/CamelCaseTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/CamelCaseTest.java b/src/test/java/org/apache/freemarker/core/CamelCaseTest.java index bed87ea..a3da802 100644 --- a/src/test/java/org/apache/freemarker/core/CamelCaseTest.java +++ b/src/test/java/org/apache/freemarker/core/CamelCaseTest.java @@ -324,13 +324,6 @@ public class CamelCaseTest extends TemplateTest { assertOutput( squared("<#noparse></#noParse></#noparse>", squared), squared("</#noParse>", squared)); - - assertOutput( - squared("<#forEach x in 1..3>${x}</#forEach>", squared), - "123"); - assertOutput( - squared("<#foreach x in 1..3>${x}</#foreach>", squared), - "123"); } private String squared(String ftl, boolean squared) { @@ -370,14 +363,7 @@ public class CamelCaseTest extends TemplateTest { assertOutput( squared("<#escape x as -x><#noEscape>${1}</#noEscape></#escape>", squared), "1"); - - assertErrorContains( - squared("<#foreach x in 1..3>${x}</#foreach>", squared), - "naming convention", "camel", "#foreach"); - assertOutput( - squared("<#forEach x in 1..3>${x}</#forEach>", squared), - "123"); - + // --- getConfiguration().setNamingConvention(Configuration.LEGACY_NAMING_CONVENTION); @@ -402,13 +388,6 @@ public class CamelCaseTest extends TemplateTest { assertOutput( squared("<#escape x as -x><#noescape>${1}</#noescape></#escape>", squared), "1"); - - assertErrorContains( - squared("<#forEach x in 1..3>${x}</#forEach>", squared), - "naming convention", "legacy", "#forEach"); - assertOutput( - squared("<#foreach x in 1..3>${x}</#foreach>", squared), - "123"); } @Test @@ -440,19 +419,7 @@ public class CamelCaseTest extends TemplateTest { assertErrorContains( "<#escape x as x + 1><#noescape></#noescape><#noEscape></#noEscape></#escape>", "naming convention", "legacy"); - assertErrorContains( - "<#forEach x in 1..3>${x}</#foreach>", - "naming convention", "camel"); - assertErrorContains( - "<#forEach x in 1..3>${x}</#forEach><#foreach x in 1..3>${x}</#foreach>", - "naming convention", "camel"); - assertErrorContains( - "<#foreach x in 1..3>${x}</#forEach>", - "naming convention", "legacy"); - assertErrorContains( - "<#foreach x in 1..3>${x}</#foreach><#forEach x in 1..3>${x}</#forEach>", - "naming convention", "legacy"); - + assertErrorContains("${x?upperCase?is_string}", "naming convention", "camel", "upperCase", "is_string"); assertErrorContains("${x?upper_case?isString}", http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/java/org/apache/freemarker/core/ListErrorsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/freemarker/core/ListErrorsTest.java b/src/test/java/org/apache/freemarker/core/ListErrorsTest.java index c79be04..b798a35 100644 --- a/src/test/java/org/apache/freemarker/core/ListErrorsTest.java +++ b/src/test/java/org/apache/freemarker/core/ListErrorsTest.java @@ -52,30 +52,24 @@ public class ListErrorsTest extends TemplateTest { "#items", "must be inside", "#list"); assertErrorContains("<#list xs><#macro m><#items as x></#items></#macro></#list>", "#items", "must be inside", "#list"); - assertErrorContains("<#list xs><#forEach x in xs><#items as x></#items></#forEach></#list>", - "#forEach", "doesn't support", "#items"); assertErrorContains("<#list xs as x><#items as x>${x}</#items></#list>", "#list", "must not have", "#items", "as loopVar"); assertErrorContains("<#list xs><#list xs as x><#items as x>${x}</#items></#list></#list>", "#list", "must not have", "#items", "as loopVar"); assertErrorContains("<#list xs></#list>", "#list", "must have", "#items", "as loopVar"); - assertErrorContains("<#forEach x in xs><#items as x></#items></#forEach>", - "#forEach", "doesn't support", "#items"); - assertErrorContains("<#list xs><#forEach x in xs><#items as x></#items></#forEach></#list>", - "#forEach", "doesn't support", "#items"); } @Test public void testInvalidSepParseTime() throws IOException, TemplateException { assertErrorContains("<#sep>, </#sep>", - "#sep", "must be inside", "#list", "#foreach"); + "#sep", "must be inside", "#list"); assertErrorContains("<#sep>, ", - "#sep", "must be inside", "#list", "#foreach"); + "#sep", "must be inside", "#list"); assertErrorContains("<#list xs as x><#else><#sep>, </#list>", - "#sep", "must be inside", "#list", "#foreach"); + "#sep", "must be inside", "#list"); assertErrorContains("<#list xs as x><#macro m><#sep>, </#macro></#list>", - "#sep", "must be inside", "#list", "#foreach"); + "#sep", "must be inside", "#list"); } @Test http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl index 3889765..a711d4d 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/comparisons.ftl @@ -67,7 +67,7 @@ <p>The comparison operators:</p> <#assign list1 = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]> -<#foreach item in list1> +<#list list1 as item> <p>Item is: ${item}</p> <#if item lt 5> <p>Item is less than five.</p> @@ -81,7 +81,7 @@ <#if (item >= 10)> <p>Item is greater than or equal to ten.</p> </#if> -</#foreach> +</#list> <#-- Signum-based optimization test, all 9 permutations: --> <#-- 1 --> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl index 393058e..41f8425 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/interpret.ftl @@ -17,7 +17,7 @@ under the License. --> <#global x=["a", "b", "c"]> -<#global templateSource = r"<#foreach y in x>${y}</#foreach>"> +<#global templateSource = r"<#list x as y>${y}</#list>"> <@templateSource?interpret>def</@> <@[templateSource]?interpret>def</@> <@[templateSource,"id"]?interpret>def</@> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/iterators.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/iterators.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/iterators.ftl index 0b0e64d..2fd9b21 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/iterators.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/iterators.ftl @@ -31,9 +31,9 @@ <p>Now iterate over a list:</p> -<#foreach item in list> +<#list list as item> <p>${item}</p> -</#foreach> +</#list> <p>Now iterate again:</p> @@ -47,13 +47,13 @@ <p>${item}</p> </#list> -<#foreach item in hash.key> +<#list hash.key as item> <p>${item}</p> -</#foreach> +</#list> -<#foreach item in hash[ "key" ]> +<#list hash[ "key" ] as item> <p>${item}</p> -</#foreach> +</#list> <#list hash["key"] as item> <p>${item}</p> @@ -65,9 +65,9 @@ <p>${key}</p> </#list> -<#foreach az in hash2.value.key> +<#list hash2.value.key as az> <p>${az}</p> -</#foreach> +</#list> </body> </html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/listliteral.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/listliteral.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/listliteral.ftl index 6503864..d48578c 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/listliteral.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/listliteral.ftl @@ -34,51 +34,51 @@ The list contains #{test?size} items. -<#foreach item in test> +<#list test as item> <p>${item}</p> -</#foreach> +</#list> <p>Now update the assignment and repeat:</p> <#assign mymessage = "world"> -<#foreach item in test> +<#list test as item> <p>${item}</p> -</#foreach> +</#list> <p>Now reassign the list and repeat:</p> <#assign test = [ hash.temp, "test1", "test23", "test45", mymessage, "hash", hash["temp"]]> <#assign test = [ "foo", "bar" ] + test> -<#foreach item in test[1..4]> +<#list test[1..4] as item> <p>${item}</p> -</#foreach> +</#list> <p>Silly, but necessary tests, for one and zero element lists:</p> <#assign test = [ "Hello, world" ]> -<#foreach item in test> +<#list test as item> <p>${item}</p> -</#foreach> +</#list> <p>Zero item test:</p> <#assign test = []> -<#foreach item in test> +<#list test as item> <p>${item}</p> -</#foreach> +</#list> <p>Dumb test for number literals -- these weren't working as expected:</p> <#assign test = [] + [1, 2,3, 5, 7]> -<#foreach item in test> +<#list test as item> <p>${item}</p> <#if item == 5><#break></#if> -</#foreach> +</#list> </body> </html> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/multimodels.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/multimodels.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/multimodels.ftl index 6d26fa7..f356386 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/multimodels.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/multimodels.ftl @@ -32,8 +32,8 @@ hash as a single class. Let's try some tests...</p> <p>Now as a list...</p> -<#foreach item in data>${item}<br /> -</#foreach> +<#list data as item>${item}<br /> +</#list> <p>Index into a list...</p> <p>${data[ 1 ]}</p> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/nested.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/nested.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/nested.ftl index 5922177..46f4492 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/nested.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/nested.ftl @@ -18,9 +18,9 @@ --> <#macro repeat count> <#local y = "test"> - <#foreach x in 1..count> + <#list 1..count as x> ${y} ${count}/${x}: <#nested x, "asdf"> <#-- the second body parameter is not used below --> - </#foreach> + </#list> </#macro> <@repeat count=3>${y?default("undefined")} ${x?default("undefined")} ${count?default("undefined")}</@repeat> <#global x = "X"> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl index 02237b0..0e18520 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/string-builtins1.ftl @@ -57,8 +57,8 @@ xhtml: ${"\"Blah's is > 1 & < 2\""?xhtml} word_list: <#global words = x?word_list> -<#foreach shortvariablenamesmakeyourcodemorereadable in words>- ${shortvariablenamesmakeyourcodemorereadable} -</#foreach> +<#list words as w>- ${w} +</#list> <#global canufeelitbabe = x?interpret> interpret: <@canufeelitbabe></@> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/switch.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/switch.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/switch.ftl index 4404307..6bbab3c 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/switch.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/switch.ftl @@ -27,7 +27,7 @@ "squirrel", "zebra" ]> <#assign favoriteAnimal = "kiwi"> -<#foreach animal in animalList> +<#list animalList as animal> <p>Animal is: ${animal}.<br /> <#switch animal> <#case "zebra"> @@ -48,7 +48,7 @@ <#break> </#switch> </p> -</#foreach> +</#list> <#-- Nesting and no-match --> <#list [ 1, 2, 3 ] as x> http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/type-builtins.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/type-builtins.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/type-builtins.ftl index a576e95..cb0f576 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/type-builtins.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/type-builtins.ftl @@ -18,13 +18,13 @@ --> <#setting boolean_format="1,0"> StNuBoMeTaMaHaHxSeCoCxEnInDiNo -<#foreach x in [ +<#list [ "a", 1, false, testmethod, testmacro, html_escape, {"a":1}, [1], testcollection, testcollectionEx, testnode, bean, bean.m, bean.mOverloaded -]> +] as x> ${x?is_string} <#t> ${x?is_number} <#t> ${x?is_boolean} <#t> @@ -40,5 +40,5 @@ StNuBoMeTaMaHaHxSeCoCxEnInDiNo ${x?is_indexable} <#t> ${x?is_directive} <#t> ${x?is_node}<#lt> -</#foreach> +</#list> <#macro testmacro></#macro> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/e3486d9e/src/test/resources/org/apache/freemarker/test/templatesuite/templates/xml.ftl ---------------------------------------------------------------------- diff --git a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/xml.ftl b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/xml.ftl index bae3067..b85fc03 100644 --- a/src/test/resources/org/apache/freemarker/test/templatesuite/templates/xml.ftl +++ b/src/test/resources/org/apache/freemarker/test/templatesuite/templates/xml.ftl @@ -18,11 +18,11 @@ --> <#-- test processing instructions --> <#global PIs = doc._content._ftype("p")> -<#foreach pi in PIs> +<#list PIs as pi> ${pi} ${pi["@target"]._text} ${pi["@data"]._text} -</#foreach> +</#list> ${PIs?size} <#global firstPi = PIs[0]> ${firstPi._type} @@ -37,11 +37,11 @@ ${docRoot["ns:e1"]["@a1"]._name} ${docRoot["ns:e1"]["@a2"]._text} ${docRoot._children._parent._name} ${docRoot._children._parent._unique._name} -<#foreach d in doc._descendant> +<#list doc._descendant as d> ${d._name} -</#foreach> -<#foreach d in doc._descendant._ancestorOrSelf> +</#list> +<#list doc._descendant._ancestorOrSelf as d> ${d._name} -</#foreach> +</#list> ${docRoot["ns:e2"]["ns:e12"]._text} ${docRoot["ns:e2"]["ns:e12"]._plaintext}
