freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject freemarker git commit: The `tagSyntax` setting doesn't support the `autoDetect` value anymore. It was removed mostly because tools (editors) could almost never implement it. Instead, there will be separate file extensions for each syntax variation.
Date Sun, 01 Apr 2018 21:10:33 GMT
Repository: freemarker
Updated Branches:
  refs/heads/3 55557af21 -> 0c106643f


The `tagSyntax` setting doesn't support the `autoDetect` value anymore. It was removed mostly
because tools (editors) could almost never implement it. Instead, there will be separate file
extensions for each syntax variation.


Project: http://git-wip-us.apache.org/repos/asf/freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/freemarker/commit/0c106643
Tree: http://git-wip-us.apache.org/repos/asf/freemarker/tree/0c106643
Diff: http://git-wip-us.apache.org/repos/asf/freemarker/diff/0c106643

Branch: refs/heads/3
Commit: 0c106643f2c9bd0a30afdd606ad1aae324eeba8e
Parents: 55557af
Author: ddekany <ddekany@apache.org>
Authored: Sun Apr 1 23:10:20 2018 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Sun Apr 1 23:10:20 2018 +0200

----------------------------------------------------------------------
 FM3-CHANGE-LOG.txt                              |  3 ++
 .../freemarker/core/ActualTagSyntaxTest.java    | 16 +-----
 .../core/InterpretSettingInheritanceTest.java   |  9 ----
 .../MutableProcessingConfigurationTest.java     |  2 +-
 .../core/ObjectBuilderSettingsTest.java         |  2 +-
 .../core/ParsingErrorMessagesTest.java          | 40 +++++++++------
 .../core/TagSyntaxVariationsTest.java           | 51 --------------------
 ...utableParsingAndProcessingConfiguration.java |  7 ++-
 .../freemarker/core/ParsingConfiguration.java   | 10 +---
 .../org/apache/freemarker/core/TagSyntax.java   |  8 ---
 .../org/apache/freemarker/core/Template.java    |  3 +-
 freemarker-core/src/main/javacc/FTL.jj          | 16 ------
 .../apache/freemarker/test/TemplateTest.java    | 44 +++++++++++++++--
 13 files changed, 79 insertions(+), 132 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt
index 2b669c0..f9c6da8 100644
--- a/FM3-CHANGE-LOG.txt
+++ b/FM3-CHANGE-LOG.txt
@@ -72,6 +72,7 @@ Major template language changes / features
     and empty hash).
   - [TODO] Deeper changes are supposed to happen here later. (Some of the above changes will
be meaningless then.)
 
+  
 Smaller template language changes
 ---------------------------------
 
@@ -288,6 +289,8 @@ Core / Configuration
 - Removed the wrapUncheckedExceptions setting. FreeMarker now behaves as if it was true.
 - Removed the strictSyntax setting, and so also the support for FTL tags without #. This
was a FreeMarker 1.x
   compatibility option.
+- The `tagSyntax` setting doesn't support the `autoDetect` value anymore. It was removed
mostly because tools (editors)
+  could almost never implement it. Instead, there will be ([TODO]) separate file extensions
for each syntax variation.
 - Renamed the `cacheStorage` Configuration setting to `templateCacheStorage`.
 - Renamed the `localizedLookup` Configuration setting to `localizedTemplateLookup`.
 - Renamed the `datetimeFormat` Configuration setting to `dateTimeFormat` (following Java
8 convention).

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core-test/src/test/java/org/apache/freemarker/core/ActualTagSyntaxTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ActualTagSyntaxTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ActualTagSyntaxTest.java
index 02d7f3d..84813df 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ActualTagSyntaxTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ActualTagSyntaxTest.java
@@ -31,7 +31,6 @@ public class ActualTagSyntaxTest {
 
     @Test
     public void testWithFtlHeader() throws IOException {
-        testWithFtlHeader(AUTO_DETECT);
         testWithFtlHeader(ANGLE_BRACKET);
         testWithFtlHeader(SQUARE_BRACKET);
     }
@@ -43,26 +42,15 @@ public class ActualTagSyntaxTest {
     
     @Test
     public void testUndecidable() throws IOException {
-        assertEquals(getActualTagSyntax("foo", AUTO_DETECT), ANGLE_BRACKET);
         assertEquals(getActualTagSyntax("foo", ANGLE_BRACKET), ANGLE_BRACKET);
         assertEquals(getActualTagSyntax("foo", SQUARE_BRACKET), SQUARE_BRACKET);
     }
 
-    @Test
-    public void testDecidableWithoutFtlHeader() throws IOException {
-        assertEquals(getActualTagSyntax("foo<#if true></#if>", AUTO_DETECT),
ANGLE_BRACKET);
-        assertEquals(getActualTagSyntax("foo<#if true></#if>", ANGLE_BRACKET),
ANGLE_BRACKET);
-        assertEquals(getActualTagSyntax("foo<#if true></#if>", SQUARE_BRACKET),
SQUARE_BRACKET);
-        
-        assertEquals(getActualTagSyntax("foo[#if true][/#if]", AUTO_DETECT), SQUARE_BRACKET);
-        assertEquals(getActualTagSyntax("foo[#if true][/#if]", ANGLE_BRACKET), ANGLE_BRACKET);
-        assertEquals(getActualTagSyntax("foo[#if true][/#if]", SQUARE_BRACKET), SQUARE_BRACKET);
-    }
-    
     private TagSyntax getActualTagSyntax(String ftl, TagSyntax cfgTagSyntax) throws IOException
{
         return new Template(
                 null, ftl,
-                new TestConfigurationBuilder().tagSyntax(cfgTagSyntax).build()).getActualTagSyntax();
+                new TestConfigurationBuilder().tagSyntax(cfgTagSyntax).build())
+                .getActualTagSyntax();
     }
     
 }

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpretSettingInheritanceTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpretSettingInheritanceTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpretSettingInheritanceTest.java
index dd4f899..9132d11 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpretSettingInheritanceTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/InterpretSettingInheritanceTest.java
@@ -56,15 +56,6 @@ public class InterpretSettingInheritanceTest  extends TemplateTest {
         assertOutput(FTL_S_S_A, OUT_S_A_WHEN_SYNTAX_IS_S);
         assertOutput(FTL_A_A_S, OUT_A_S_WHEN_SYNTAX_IS_S);
         assertOutput(FTL_A_S_A, OUT_S_A_WHEN_SYNTAX_IS_S);
-
-        setConfiguration(new TestConfigurationBuilder()
-                .tagSyntax(TagSyntax.AUTO_DETECT)
-                .build());
-        assertOutput(FTL_S_A_S, OUT_A_S_WHEN_SYNTAX_IS_A);
-        assertOutput(FTL_S_S_A, OUT_S_A_WHEN_SYNTAX_IS_S);
-        assertOutput(FTL_A_A_S, OUT_A_S_WHEN_SYNTAX_IS_A);
-        assertOutput(FTL_A_S_A, OUT_S_A_WHEN_SYNTAX_IS_S);
-        assertOutput("<@'[#ftl]x'?interpret />[#if true]y[/#if]", "x[#if true]y[/#if]");
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
index 0d764be..62a9bfb 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/MutableProcessingConfigurationTest.java
@@ -279,7 +279,7 @@ public class MutableProcessingConfigurationTest {
         new Template(
                 null, "${m?api.hashCode()}",
                 new Configuration.Builder(Configuration.VERSION_3_0_0).apiBuiltinEnabled(true).build())
-                .process(Collections.singletonMap("m", new HashMap()), _NullWriter.INSTANCE);
+                .process(Collections.singletonMap("m", new HashMap<>()), _NullWriter.INSTANCE);
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core-test/src/test/java/org/apache/freemarker/core/ObjectBuilderSettingsTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ObjectBuilderSettingsTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ObjectBuilderSettingsTest.java
index f93d9ce..a168563 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ObjectBuilderSettingsTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ObjectBuilderSettingsTest.java
@@ -904,7 +904,7 @@ public class ObjectBuilderSettingsTest {
         assertEqualsEvaled(123, "org.apache.freemarker.core.ObjectBuilderSettingsTest$TestStaticFields.CONST");
         
         // With shorthand class name:
-        assertEqualsEvaled(TagSyntax.AUTO_DETECT, "TagSyntax.AUTO_DETECT");
+        assertEqualsEvaled(TagSyntax.SQUARE_BRACKET, "TagSyntax.SQUARE_BRACKET");
         
         try {
             _ObjectBuilderSettingEvaluator.eval(

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core-test/src/test/java/org/apache/freemarker/core/ParsingErrorMessagesTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ParsingErrorMessagesTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ParsingErrorMessagesTest.java
index 54ee8a9..a3dcd6c 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/ParsingErrorMessagesTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/ParsingErrorMessagesTest.java
@@ -27,13 +27,6 @@ import org.junit.Test;
 
 public class ParsingErrorMessagesTest extends TemplateTest {
 
-    @Override
-    protected Configuration createDefaultConfiguration() throws Exception {
-        return new TestConfigurationBuilder()
-                .tagSyntax(TagSyntax.AUTO_DETECT)
-                .build();
-    }
-
     @Test
     public void testNeedlessInterpolation() {
         assertErrorContainsAS("<#if ${x} == 3></#if>", "instead of ${");
@@ -177,10 +170,10 @@ public class ParsingErrorMessagesTest extends TemplateTest {
         assertErrorContainsAS("<#function f(a=0, b)></#function>", "with default",
"without a default");
         assertErrorContainsAS("<#function f(a,)></#function>", "Comma without");
         assertErrorContainsAS("<#macro m a{positional}, b{positional},></#macro>",
"Comma without");
-        assertErrorContains("<#function f(a, b></#function>");
-        assertErrorContainsAS("<#function f(></#function>");
-        assertErrorContainsAS("[#ftl][#function f(a, b][/#function]", "Missing closing \")\"");
-        assertErrorContainsAS("[#ftl][#function f(][/#function]", "Missing closing \")\"");
+        assertErrorContainsAS("<#function f(a, b></#function>",
+                    new String[] { ">" }, new String[] { "Missing closing \")\"" });
+        assertErrorContainsAS("<#function f(></#function>",
+                    new String[] { ">" }, new String[] { "Missing closing \")\"" });
         assertErrorContainsAS("<#macro m a b)></#macro>", "\")\" without", "opening");
         assertErrorContainsAS("<#macro m a b a></#macro>", "\"a\"", "multiple");
     }
@@ -190,9 +183,28 @@ public class ParsingErrorMessagesTest extends TemplateTest {
      * Beware, it uses primitive search-and-replace.
      */
     protected Throwable assertErrorContainsAS(String angleBracketsFtl, String... expectedSubstrings)
{
-        assertErrorContains(angleBracketsFtl, expectedSubstrings);
-        angleBracketsFtl = angleBracketsFtl.replace('<', '[').replace('>', ']');
-        return assertErrorContains(angleBracketsFtl, expectedSubstrings);
+        return assertErrorContainsAS(angleBracketsFtl, expectedSubstrings, expectedSubstrings);
+    }
+    
+    protected Throwable assertErrorContainsAS(String angleBracketsFtl,
+            String[] expectedSubstringsA, String[] expectedSubstringsS) {
+        pushNamelessTemplateConfiguraitonSettings(new TemplateConfiguration.Builder()
+                    .tagSyntax(TagSyntax.ANGLE_BRACKET)
+                    .build());
+        try {
+            assertErrorContains(angleBracketsFtl, expectedSubstringsA);
+        } finally {
+            popNamelessTemplateConfiguraitonSettings();
+        }
+        
+        pushNamelessTemplateConfiguraitonSettings(new TemplateConfiguration.Builder()
+                .tagSyntax(TagSyntax.SQUARE_BRACKET)
+                .build());
+        try {
+            return assertErrorContains(angleBracketsFtl.replace('<', '[').replace('>',
']'), expectedSubstringsS);
+        } finally {
+            popNamelessTemplateConfiguraitonSettings();
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core-test/src/test/java/org/apache/freemarker/core/TagSyntaxVariationsTest.java
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TagSyntaxVariationsTest.java
b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TagSyntaxVariationsTest.java
index 51286b4..320f2b7 100644
--- a/freemarker-core-test/src/test/java/org/apache/freemarker/core/TagSyntaxVariationsTest.java
+++ b/freemarker-core-test/src/test/java/org/apache/freemarker/core/TagSyntaxVariationsTest.java
@@ -111,57 +111,6 @@ public class TagSyntaxVariationsTest extends TestCase {
                             cust_xxx + wrongx_xxx + dir_xxx,
                             null);
                 } // for wrongc
-            } // for squ
-
-            {
-                Configuration cfg = new TestConfigurationBuilder()
-                        .tagSyntax(TagSyntax.AUTO_DETECT)
-                        .sharedVariables(sharedVariables)
-                        .build();
-                for (int perm = 0; perm < 4; perm++) {
-                    // All 4 permutations
-                    String wrong_xxx = (perm & 1) == 0 ? WRONG_ANG : WRONG_SQU;
-                    String dir_xxx = (perm & 2) == 0 ? dir_ang : dir_squ;
-
-                    test(cfg,
-                            wrong_xxx + dir_xxx,
-                            null);
-                } // for perm
-            }
-
-            {
-                Configuration cfg = new TestConfigurationBuilder()
-                        .tagSyntax(TagSyntax.AUTO_DETECT)
-                        .sharedVariables(sharedVariables)
-                        .build();
-                // Permutations
-                for (int angOrSquStart = 0; angOrSquStart < 2; angOrSquStart++) {
-                    String hdr_xxx = angOrSquStart == 0 ? HDR_ANG : HDR_SQU;
-                    String cust_xxx = angOrSquStart == 0 ? CUST_ANG : CUST_SQU;
-                    String wrong_yyy = angOrSquStart != 0 ? WRONG_ANG : WRONG_SQU;
-                    String dir_xxx = angOrSquStart == 0 ? dir_ang : dir_squ;
-                    String dir_yyy = angOrSquStart != 0 ? dir_ang : dir_squ;
-
-                    test(cfg,
-                            cust_xxx + wrong_yyy + dir_xxx,
-                            CUST_OUT + wrong_yyy + dir_out);
-
-                    test(cfg,
-                            hdr_xxx + wrong_yyy + dir_xxx,
-                            wrong_yyy + dir_out);
-
-                    test(cfg,
-                            cust_xxx + wrong_yyy + dir_yyy,
-                            CUST_OUT + wrong_yyy + dir_yyy);
-
-                    test(cfg,
-                            hdr_xxx + wrong_yyy + dir_yyy,
-                            wrong_yyy + dir_yyy);
-
-                    test(cfg,
-                            dir_xxx + wrong_yyy + dir_yyy,
-                            dir_out + wrong_yyy + dir_yyy);
-                } // for squStart
             } // for assign
         }
     }

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
index ef174ab..4bbbe64 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/MutableParsingAndProcessingConfiguration.java
@@ -127,17 +127,16 @@ public abstract class MutableParsingAndProcessingConfiguration<
                     throw new InvalidSettingValueException(name, value, "Unsupported template
language name");
                 }
             } else if (TAG_SYNTAX_KEY.equals(name)) {
-                if ("autoDetect".equals(value)) {
-                    setTagSyntax(TagSyntax.AUTO_DETECT);
-                } else if ("angleBracket".equals(value)) {
+                if ("angleBracket".equals(value)) {
                     setTagSyntax(TagSyntax.ANGLE_BRACKET);
                 } else if ("squareBracket".equals(value)) {
                     setTagSyntax(TagSyntax.SQUARE_BRACKET);
                 } else {
                     throw new InvalidSettingValueException(name, value,
-                            "auto_detect".equals(value) ? "The correct value is: autoDetect"
:
                             "angle_bracket".equals(value) ? "The correct value is: angleBracket"
:
                             "square_bracket".equals(value) ? "The correct value is: squareBracket"
:
+                            "autoDetect".equals(value) || "auto_detect".equals(value)
+                                    ? "The autoDetect tag syntax is not supported since 3.0.0."
:
                             "No such predefined tag syntax name");
                 }
             } else if (INTERPOLATION_SYNTAX_KEY.equals(name)) {

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
index 66b237c..8e43a53 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ParsingConfiguration.java
@@ -52,22 +52,14 @@ public interface ParsingConfiguration {
      * 
      * <p>The {@code tagSyntax} parameter must be one of:
      * <ul>
-     *   <li>{@link TagSyntax#AUTO_DETECT}:
-     *     Use the syntax of the first FreeMarker tag (can be anything, like <tt>#list</tt>,
-     *     <tt>#include</tt>, user defined, etc.)
      *   <li>{@link TagSyntax#ANGLE_BRACKET}:
-     *     Use the angle bracket tag syntax (the normal syntax), like {@code <#include
...>}
+     *     Use the angle bracket tag syntax (the normal syntax), like {@code <#include
...>}. This is the default.
      *   <li>{@link TagSyntax#SQUARE_BRACKET}:
      *     Use the square bracket tag syntax, like {@code [#include ...]}. Note that this
does <em>not</em> change
      *     <code>${x}</code> to {@code [=...]}; that's <em>interpolation</em>
syntax, so there the relevant one is
      *     {@link #getInterpolationSyntax()}.
      * </ul>
      *
-     * <p>In FreeMarker 2.3.x {@link TagSyntax#ANGLE_BRACKET} is the
-     * default for better backward compatibility. Starting from 2.4.x {@link
-     * TagSyntax#AUTO_DETECT} is the default, so it's recommended to use
-     * that even for 2.3.x.
-     *
      * <p>This setting is ignored for the templates that have {@code ftl} directive
in
      * it. For those templates the syntax used for the {@code ftl} directive determines
      * the syntax.

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core/src/main/java/org/apache/freemarker/core/TagSyntax.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/TagSyntax.java b/freemarker-core/src/main/java/org/apache/freemarker/core/TagSyntax.java
index b841484..776c64c 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/TagSyntax.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/TagSyntax.java
@@ -24,14 +24,6 @@ package org.apache.freemarker.core;
  */
 public enum TagSyntax {
     
-    /**
-     * The parser decides between {@link #ANGLE_BRACKET} and {@link #SQUARE_BRACKET} based
on the first tag (like
-     * {@code [#if x]} or {@code <#if x>}) it mets. Note that {@code [=...]} is <em>not</em>
a tag, but
-     * an interpolation, so it's not used for tag syntax auto-detection.
-     */
-    // TODO [FM3] Get rid of this, as it's too hard for tooling.
-    AUTO_DETECT,
-    
     /** For example {@code <#if x><@foo /></#if>} */
     ANGLE_BRACKET,
     

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
index 4036b3d..25cbcd2 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/Template.java
@@ -681,8 +681,7 @@ public class Template implements ProcessingConfiguration, CustomStateScope
{
      * Returns the tag syntax the parser has chosen for this template. If the syntax could
be determined, it's
      * {@link TagSyntax#SQUARE_BRACKET} or {@link TagSyntax#ANGLE_BRACKET}. If the syntax
      * couldn't be determined (like because there was no tags in the template, or it was
a plain text template), this
-     * returns whatever the default is in the current configuration, so it's maybe
-     * {@link TagSyntax#AUTO_DETECT}.
+     * returns whatever the default is in the current configuration.
      * 
      * @see ParsingConfiguration#getTagSyntax()
      */

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-core/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/javacc/FTL.jj b/freemarker-core/src/main/javacc/FTL.jj
index f49d76e..f0cc85e 100644
--- a/freemarker-core/src/main/javacc/FTL.jj
+++ b/freemarker-core/src/main/javacc/FTL.jj
@@ -159,9 +159,6 @@ public class FMParser {
 
         TagSyntax tagSyntax = pCfg.getTagSyntax();
         switch (tagSyntax) {
-        case AUTO_DETECT:
-            token_source.autodetectTagSyntax = true;
-            break;
         case ANGLE_BRACKET:
             token_source.squBracTagSyntax = false;
             break;
@@ -532,7 +529,6 @@ TOKEN_MGR_DECLS:
     private int bracketNesting;
     private boolean inFTLHeader;
     boolean squBracTagSyntax,
-            autodetectTagSyntax,
             tagSyntaxEstablished,
             inNamedParameterExpression;
     InterpolationSyntax interpolationSyntax;
@@ -550,9 +546,6 @@ TOKEN_MGR_DECLS:
         final String image = tok.image;
         
         char firstChar = image.charAt(0);
-        if (autodetectTagSyntax && !tagSyntaxEstablished) {
-            squBracTagSyntax = (firstChar == '[');
-        }
         if ((firstChar == '[' && !squBracTagSyntax) || (firstChar == '<' &&
squBracTagSyntax)) {
             tok.kind = STATIC_TEXT_NON_WS;
             return;
@@ -596,9 +589,6 @@ TOKEN_MGR_DECLS:
 
     private void dynamicTopLevelCall(Token tok) {
         char firstChar = tok.image.charAt(0);
-        if (autodetectTagSyntax && !tagSyntaxEstablished) {
-            squBracTagSyntax = (firstChar == '[');
-        }
         if (squBracTagSyntax && firstChar == '<') {
             tok.kind = STATIC_TEXT_NON_WS;
             return;
@@ -689,7 +679,6 @@ TOKEN_MGR_DECLS:
         if (!tagSyntaxEstablished) {
             squBracTagSyntax = matchedToken.image.charAt(0) == '[';
             tagSyntaxEstablished = true;
-            autodetectTagSyntax = false;
         }
         String img = matchedToken.image;
         char firstChar = img.charAt(0);
@@ -881,11 +870,6 @@ TOKEN:
     {
         char firstChar = matchedToken.image.charAt(0);
 
-        if (!tagSyntaxEstablished && autodetectTagSyntax) {
-            squBracTagSyntax = (firstChar == '[');
-            tagSyntaxEstablished = true;
-        }
-
         if (firstChar == '<' && squBracTagSyntax) {
             matchedToken.kind = STATIC_TEXT_NON_WS;
         } else if (firstChar == '[' && !squBracTagSyntax) {

http://git-wip-us.apache.org/repos/asf/freemarker/blob/0c106643/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java
----------------------------------------------------------------------
diff --git a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java
b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java
index a7d31f4..5915ae3 100644
--- a/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java
+++ b/freemarker-test-utils/src/main/java/org/apache/freemarker/test/TemplateTest.java
@@ -30,6 +30,7 @@ import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.Map;
 import java.util.Properties;
 
@@ -37,6 +38,8 @@ import org.apache.commons.io.IOUtils;
 import org.apache.freemarker.core.Configuration;
 import org.apache.freemarker.core.ParseException;
 import org.apache.freemarker.core.Template;
+import org.apache.freemarker.core.TemplateConfiguration;
+import org.apache.freemarker.core.TemplateConfiguration.Builder;
 import org.apache.freemarker.core.TemplateException;
 import org.apache.freemarker.core.templateresolver.TemplateLoader;
 import org.apache.freemarker.core.templateresolver.impl.ByteArrayTemplateLoader;
@@ -57,6 +60,7 @@ public abstract class TemplateTest {
     private boolean dataModelCreated;
     private Object dataModel;
     private Map<String, String> addedTemplates = new HashMap<>();
+    private LinkedList<TemplateConfiguration> tcStack = new LinkedList<>();
 
     /**
      * Gets the {@link Configuration} used, automatically creating and setting if it wasn't
yet.
@@ -74,6 +78,8 @@ public abstract class TemplateTest {
 
     /**
      * @param configuration Usually should be built using {@link TestConfigurationBuilder};
not {@code null}.
+     * 
+     * @see #pushNamelessTemplateConfiguraitonSettings(TemplateConfiguration)
      */
     protected final void setConfiguration(Configuration configuration) {
         _NullArgumentException.check("configuration", configuration);
@@ -90,7 +96,7 @@ public abstract class TemplateTest {
     }
 
     private Template createTemplate(String ftl) throws IOException {
-        return new Template(null, ftl, getConfiguration());
+        return new Template(null, ftl, getConfiguration(), getNamelessTemplateConfiguration());
     }
 
     protected void assertOutputForNamed(String name, String expectedOut) throws IOException,
TemplateException {
@@ -293,7 +299,7 @@ public abstract class TemplateTest {
             String... expectedSubstrings) {
         assertErrorContains(name, null, exceptionClass, expectedSubstrings);
     }
-    
+
     private Throwable assertErrorContains(String name, String ftl, Class<? extends Throwable>
exceptionClass,
             String... expectedSubstrings) {
         try {
@@ -301,7 +307,7 @@ public abstract class TemplateTest {
             if (ftl == null) {
                 t = getConfiguration().getTemplate(name);
             } else {
-                t = new Template("adhoc", ftl, getConfiguration());
+                t = new Template("adhoc", ftl, getConfiguration(), getNamelessTemplateConfiguration());
             }
             t.process(getDataModel(), new StringWriter());
             fail("The template had to fail");
@@ -344,6 +350,38 @@ public abstract class TemplateTest {
     private String normalizeNewLines(String s) {
         return _StringUtils.replace(s, "\r\n", "\n").replace('\r', '\n');
     }
+    
+    /**
+     * Adds a {@link TemplateConfiguration} that will be used for further templates tested,
but not for templates that
+     * are tested with the "OfNamed" variants (which are coming from a {@link TemplateLoader}).
If a
+     * {@link TemplateConfiguration} was added earlier, this new one will be merged into
it.
+     * 
+     * @see #setConfiguration(Configuration)
+     */
+    protected void pushNamelessTemplateConfiguraitonSettings(TemplateConfiguration tc) {
+        TemplateConfiguration lastTC = tcStack.poll();
+        TemplateConfiguration mergedTC;
+        if (lastTC != null) {
+            Builder mergedTCB = new TemplateConfiguration.Builder();
+            mergedTCB.merge(lastTC);
+            mergedTCB.merge(tc);
+            mergedTC = mergedTCB.build();
+        } else {
+            mergedTC = tc;
+        }
+        tcStack.push(mergedTC);
+    }
+
+    /**
+     * Undoes the last {@link #pushNamelessTemplateConfiguraitonSettings(TemplateConfiguration)}.
+     */
+    protected void popNamelessTemplateConfiguraitonSettings() {
+        tcStack.pop();
+    }
+    
+    private TemplateConfiguration getNamelessTemplateConfiguration() {
+        return tcStack.peek();
+    }
 
     public static class TestBean {
         private int x;


Mime
View raw message