You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/01/22 00:01:59 UTC
incubator-freemarker git commit: Removed the strict_syntax setting,
and so also the support for FTL tags without #. This was a FreeMarker
1.x compatibility option. Also,
removed deprecated FMParser contstructors (some of them has taken
strictSyntaxMode a
Repository: incubator-freemarker
Updated Branches:
refs/heads/3 d0e056eaa -> 7483146d5
Removed the strict_syntax setting, and so also the support for FTL tags without #. This was a FreeMarker 1.x compatibility option. Also, removed deprecated FMParser contstructors (some of them has taken strictSyntaxMode as parameter).
Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/7483146d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/7483146d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/7483146d
Branch: refs/heads/3
Commit: 7483146d5aebf146c0732e893324d611e40186be
Parents: d0e056e
Author: ddekany <dd...@apache.org>
Authored: Sun Jan 22 00:57:12 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Sun Jan 22 01:01:46 2017 +0100
----------------------------------------------------------------------
src/main/java/freemarker/core/Configurable.java | 4 -
.../LegacyConstructorParserConfiguration.java | 142 ---------
.../freemarker/core/ParserConfiguration.java | 5 -
.../freemarker/core/TemplateConfiguration.java | 27 --
..._ParserConfigurationWithInheritedFormat.java | 13 +-
.../java/freemarker/template/Configuration.java | 51 +---
src/main/javacc/FTL.jj | 298 ++++++-------------
src/manual/en_US/FM3-CHANGE-LOG.txt | 5 +-
.../java/freemarker/core/CamelCaseTest.java | 41 +--
.../core/LegacyFMParserConstructorsTest.java | 37 ---
.../core/TemplateConfigurationTest.java | 8 -
.../freemarker/template/ConfigurationTest.java | 10 +-
.../expected/non-strict-syntax.txt | 37 ---
.../test/templatesuite/expected/noparse.txt | 8 +-
.../templatesuite/expected/strictinheader.txt | 21 --
.../test/templatesuite/templates/comment.ftl | 13 +-
.../test/templatesuite/templates/macros.ftl | 27 +-
.../templates/non-strict-syntax.ftl | 38 ---
.../test/templatesuite/templates/noparse.ftl | 25 +-
.../test/templatesuite/templates/root.ftl | 7 +-
.../templatesuite/templates/strictinheader.ftl | 23 --
.../templates/strictinheader_inc1.ftl | 21 --
.../templates/strictinheader_inc2.ftl | 20 --
.../test/templatesuite/templates/transforms.ftl | 45 ++-
.../freemarker/test/templatesuite/testcases.xml | 7 -
25 files changed, 179 insertions(+), 754 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/java/freemarker/core/Configurable.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Configurable.java b/src/main/java/freemarker/core/Configurable.java
index 704a7c0..5dc7c49 100644
--- a/src/main/java/freemarker/core/Configurable.java
+++ b/src/main/java/freemarker/core/Configurable.java
@@ -2080,10 +2080,6 @@ public class Configurable {
* {@link OutputFormat}-s.
* Example: {@code [com.example.MyOutputFormat(), com.example.MyOtherOutputFormat()]}
*
- * <li><p>{@code "strict_syntax"}:
- * See {@link Configuration#setStrictSyntaxMode}. Deprecated.
- * <br>String value: {@code "true"}, {@code "false"}, {@code yes}, etc.
- *
* <li><p>{@code "whitespace_stripping"}:
* See {@link Configuration#setWhitespaceStripping}.
* <br>String value: {@code "true"}, {@code "false"}, {@code yes}, etc.
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/java/freemarker/core/LegacyConstructorParserConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/LegacyConstructorParserConfiguration.java b/src/main/java/freemarker/core/LegacyConstructorParserConfiguration.java
deleted file mode 100644
index 2ef3b89..0000000
--- a/src/main/java/freemarker/core/LegacyConstructorParserConfiguration.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import freemarker.template.Version;
-
-/**
- * Used to work around that {@link FMParser} has constructors that have separate parameters for individual settings.
- *
- * @since 2.3.24
- */
-class LegacyConstructorParserConfiguration implements ParserConfiguration {
-
- private final int tagSyntax;
- private final int namingConvention;
- private final boolean whitespaceStripping;
- private final boolean strictSyntaxMode;
- private ArithmeticEngine arithmeticEngine;
- private Integer autoEscapingPolicy;
- private OutputFormat outputFormat;
- private Boolean recognizeStandardFileExtensions;
- private Integer tabSize;
- private final Version incompatibleImprovements;
-
- public LegacyConstructorParserConfiguration(boolean strictSyntaxMode, boolean whitespaceStripping, int tagSyntax,
- int namingConvention, Integer autoEscaping, OutputFormat outputFormat,
- Boolean recognizeStandardFileExtensions, Integer tabSize,
- Version incompatibleImprovements, ArithmeticEngine arithmeticEngine) {
- this.tagSyntax = tagSyntax;
- this.namingConvention = namingConvention;
- this.whitespaceStripping = whitespaceStripping;
- this.strictSyntaxMode = strictSyntaxMode;
- this.autoEscapingPolicy = autoEscaping;
- this.outputFormat = outputFormat;
- this.recognizeStandardFileExtensions = recognizeStandardFileExtensions;
- this.tabSize = tabSize;
- this.incompatibleImprovements = incompatibleImprovements;
- this.arithmeticEngine = arithmeticEngine;
- }
-
- public int getTagSyntax() {
- return tagSyntax;
- }
-
- public int getNamingConvention() {
- return namingConvention;
- }
-
- public boolean getWhitespaceStripping() {
- return whitespaceStripping;
- }
-
- public boolean getStrictSyntaxMode() {
- return strictSyntaxMode;
- }
-
- public Version getIncompatibleImprovements() {
- return incompatibleImprovements;
- }
-
- public ArithmeticEngine getArithmeticEngine() {
- if (arithmeticEngine == null) {
- throw new IllegalStateException();
- }
- return arithmeticEngine;
- }
-
- void setArithmeticEngineIfNotSet(ArithmeticEngine arithmeticEngine) {
- if (this.arithmeticEngine == null) {
- this.arithmeticEngine = arithmeticEngine;
- }
- }
-
- public int getAutoEscapingPolicy() {
- if (autoEscapingPolicy == null) {
- throw new IllegalStateException();
- }
- return autoEscapingPolicy.intValue();
- }
-
- void setAutoEscapingPolicyIfNotSet(int autoEscapingPolicy) {
- if (this.autoEscapingPolicy == null) {
- this.autoEscapingPolicy = Integer.valueOf(autoEscapingPolicy);
- }
- }
-
- public OutputFormat getOutputFormat() {
- if (outputFormat == null) {
- throw new IllegalStateException();
- }
- return outputFormat;
- }
-
- void setOutputFormatIfNotSet(OutputFormat outputFormat) {
- if (this.outputFormat == null) {
- this.outputFormat = outputFormat;
- }
- }
-
- public boolean getRecognizeStandardFileExtensions() {
- if (recognizeStandardFileExtensions == null) {
- throw new IllegalStateException();
- }
- return recognizeStandardFileExtensions.booleanValue();
- }
-
- void setRecognizeStandardFileExtensionsIfNotSet(boolean recognizeStandardFileExtensions) {
- if (this.recognizeStandardFileExtensions == null) {
- this.recognizeStandardFileExtensions = Boolean.valueOf(recognizeStandardFileExtensions);
- }
- }
-
- public int getTabSize() {
- if (tabSize == null) {
- throw new IllegalStateException();
- }
- return tabSize.intValue();
- }
-
- void setTabSizeIfNotSet(int tabSize) {
- if (this.tabSize == null) {
- this.tabSize = Integer.valueOf(tabSize);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/java/freemarker/core/ParserConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/ParserConfiguration.java b/src/main/java/freemarker/core/ParserConfiguration.java
index 4108952..d9c487b 100644
--- a/src/main/java/freemarker/core/ParserConfiguration.java
+++ b/src/main/java/freemarker/core/ParserConfiguration.java
@@ -51,11 +51,6 @@ public interface ParserConfiguration {
ArithmeticEngine getArithmeticEngine();
/**
- * See {@link Configuration#getStrictSyntaxMode()}.
- */
- boolean getStrictSyntaxMode();
-
- /**
* See {@link Configuration#getAutoEscapingPolicy()}.
*/
int getAutoEscapingPolicy();
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/java/freemarker/core/TemplateConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/TemplateConfiguration.java b/src/main/java/freemarker/core/TemplateConfiguration.java
index c91d7fd..353d453 100644
--- a/src/main/java/freemarker/core/TemplateConfiguration.java
+++ b/src/main/java/freemarker/core/TemplateConfiguration.java
@@ -80,7 +80,6 @@ public final class TemplateConfiguration extends Configurable implements ParserC
private Integer tagSyntax;
private Integer namingConvention;
private Boolean whitespaceStripping;
- private Boolean strictSyntaxMode;
private Integer autoEscapingPolicy;
private Boolean recognizeStandardFileExtensions;
private OutputFormat outputFormat;
@@ -217,9 +216,6 @@ public final class TemplateConfiguration extends Configurable implements ParserC
if (tc.isSQLDateAndTimeTimeZoneSet()) {
setSQLDateAndTimeTimeZone(tc.getSQLDateAndTimeTimeZone());
}
- if (tc.isStrictSyntaxModeSet()) {
- setStrictSyntaxMode(tc.getStrictSyntaxMode());
- }
if (tc.isTagSyntaxSet()) {
setTagSyntax(tc.getTagSyntax());
}
@@ -506,29 +502,6 @@ public final class TemplateConfiguration extends Configurable implements ParserC
public boolean isRecognizeStandardFileExtensionsSet() {
return recognizeStandardFileExtensions != null;
}
-
- /**
- * See {@link Configuration#setStrictSyntaxMode(boolean)}.
- */
- public void setStrictSyntaxMode(boolean strictSyntaxMode) {
- this.strictSyntaxMode = Boolean.valueOf(strictSyntaxMode);
- }
-
- /**
- * The getter pair of {@link #setStrictSyntaxMode(boolean)}.
- */
- @Override
- public boolean getStrictSyntaxMode() {
- return strictSyntaxMode != null ? strictSyntaxMode.booleanValue()
- : getParentConfiguration().getStrictSyntaxMode();
- }
-
- /**
- * Tells if this setting is set directly in this object or its value is coming from the {@link #getParent() parent}.
- */
- public boolean isStrictSyntaxModeSet() {
- return strictSyntaxMode != null;
- }
@Override
public void setStrictBeanModels(boolean strict) {
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/java/freemarker/core/_ParserConfigurationWithInheritedFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/_ParserConfigurationWithInheritedFormat.java b/src/main/java/freemarker/core/_ParserConfigurationWithInheritedFormat.java
index 8248b5c..93788fe 100644
--- a/src/main/java/freemarker/core/_ParserConfigurationWithInheritedFormat.java
+++ b/src/main/java/freemarker/core/_ParserConfigurationWithInheritedFormat.java
@@ -36,42 +36,47 @@ public final class _ParserConfigurationWithInheritedFormat implements ParserConf
this.wrappedPCfg = wrappedPCfg;
}
+ @Override
public boolean getWhitespaceStripping() {
return wrappedPCfg.getWhitespaceStripping();
}
+ @Override
public int getTagSyntax() {
return wrappedPCfg.getTagSyntax();
}
- public boolean getStrictSyntaxMode() {
- return wrappedPCfg.getStrictSyntaxMode();
- }
-
+ @Override
public OutputFormat getOutputFormat() {
return outputFormat != null ? outputFormat : wrappedPCfg.getOutputFormat();
}
+ @Override
public boolean getRecognizeStandardFileExtensions() {
return false;
}
+ @Override
public int getNamingConvention() {
return wrappedPCfg.getNamingConvention();
}
+ @Override
public Version getIncompatibleImprovements() {
return wrappedPCfg.getIncompatibleImprovements();
}
+ @Override
public int getAutoEscapingPolicy() {
return autoEscapingPolicy != null ? autoEscapingPolicy.intValue() : wrappedPCfg.getAutoEscapingPolicy();
}
+ @Override
public ArithmeticEngine getArithmeticEngine() {
return wrappedPCfg.getArithmeticEngine();
}
+ @Override
public int getTabSize() {
return wrappedPCfg.getTabSize();
}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/java/freemarker/template/Configuration.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/template/Configuration.java b/src/main/java/freemarker/template/Configuration.java
index f460eac..ea188dd 100644
--- a/src/main/java/freemarker/template/Configuration.java
+++ b/src/main/java/freemarker/template/Configuration.java
@@ -167,13 +167,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
public static final String LOCALIZED_LOOKUP_KEY = LOCALIZED_LOOKUP_KEY_SNAKE_CASE;
/** Legacy, snake case ({@code like_this}) variation of the setting name. @since 2.3.23 */
- public static final String STRICT_SYNTAX_KEY_SNAKE_CASE = "strict_syntax";
- /** Modern, camel case ({@code likeThis}) variation of the setting name. @since 2.3.23 */
- public static final String STRICT_SYNTAX_KEY_CAMEL_CASE = "strictSyntax";
- /** Alias to the {@code ..._SNAKE_CASE} variation due to backward compatibility constraints. */
- public static final String STRICT_SYNTAX_KEY = STRICT_SYNTAX_KEY_SNAKE_CASE;
-
- /** Legacy, snake case ({@code like_this}) variation of the setting name. @since 2.3.23 */
public static final String WHITESPACE_STRIPPING_KEY_SNAKE_CASE = "whitespace_stripping";
/** Modern, camel case ({@code likeThis}) variation of the setting name. @since 2.3.23 */
public static final String WHITESPACE_STRIPPING_KEY_CAMEL_CASE = "whitespaceStripping";
@@ -323,7 +316,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
OUTPUT_FORMAT_KEY_SNAKE_CASE,
RECOGNIZE_STANDARD_FILE_EXTENSIONS_KEY_SNAKE_CASE,
REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_SNAKE_CASE,
- STRICT_SYNTAX_KEY_SNAKE_CASE,
TAB_SIZE_KEY_SNAKE_CASE,
TAG_SYNTAX_KEY_SNAKE_CASE,
TEMPLATE_CONFIGURATIONS_KEY_SNAKE_CASE,
@@ -345,7 +337,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
OUTPUT_FORMAT_KEY_CAMEL_CASE,
RECOGNIZE_STANDARD_FILE_EXTENSIONS_KEY_CAMEL_CASE,
REGISTERED_CUSTOM_OUTPUT_FORMATS_KEY_CAMEL_CASE,
- STRICT_SYNTAX_KEY_CAMEL_CASE,
TAB_SIZE_KEY_CAMEL_CASE,
TAG_SYNTAX_KEY_CAMEL_CASE,
TEMPLATE_CONFIGURATIONS_KEY_CAMEL_CASE,
@@ -494,7 +485,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
private static volatile Configuration defaultConfig;
- private boolean strictSyntax = true;
private volatile boolean localizedLookup = true;
private boolean whitespaceStripping = true;
private int autoEscapingPolicy = ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY;
@@ -1550,23 +1540,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
return cache.getDelay();
}
- /**
- * Sets whether directives such as {@code if}, {@code else}, etc must be written as {@code #if}, {@code #else}, etc.
- * Defaults to {@code true}.
- *
- * <p>When this is {@code true},
- * any tag not starting with <# or </# or <@ or </@ is considered as plain text
- * and will go to the output as is. Tag starting with <# or </# must
- * be valid FTL tag, or else the template is invalid (i.e. <#noSuchDirective>
- * is an error).
- *
- * @deprecated Only {@code true} (the default) value will be supported sometimes in the future.
- */
- @Deprecated
- public void setStrictSyntaxMode(boolean b) {
- strictSyntax = b;
- }
-
@Override
public void setObjectWrapper(ObjectWrapper objectWrapper) {
ObjectWrapper prevObjectWrapper = getObjectWrapper();
@@ -1669,14 +1642,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
}
/**
- * The getter pair of {@link #setStrictSyntaxMode}.
- */
- @Override
- public boolean getStrictSyntaxMode() {
- return strictSyntax;
- }
-
- /**
* Use {@link #Configuration(Version)} instead if possible; see the meaning of the parameter there.
* If the default value of a setting depends on the {@code incompatibleImprovements} and the value of that setting
* was never set in this {@link Configuration} object through the public API, its value will be set to the default
@@ -2228,12 +2193,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
* convention is enforced on all templates. Thus such a setup can be used to enforce an application-wide naming
* convention.
*
- * <p>
- * Non-strict tags (a long deprecated syntax from FreeMarker 1, activated via {@link #setStrictSyntaxMode(boolean)})
- * are only recognized as FTL tags when they are using the {@link Configuration#LEGACY_NAMING_CONVENTION} syntax,
- * regardless of this setting. As they aren't exempt from the naming convention consistency enforcement, generally,
- * you can't use strict {@link Configuration#CAMEL_CASE_NAMING_CONVENTION} tags mixed with non-strict tags.
- *
* @param namingConvention
* One of the {@link #AUTO_DETECT_NAMING_CONVENTION} or {@link #LEGACY_NAMING_CONVENTION}
* {@link #CAMEL_CASE_NAMING_CONVENTION}.
@@ -2858,8 +2817,6 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
setDefaultEncoding(value);
} else if (LOCALIZED_LOOKUP_KEY_SNAKE_CASE.equals(name) || LOCALIZED_LOOKUP_KEY_CAMEL_CASE.equals(name)) {
setLocalizedLookup(StringUtil.getYesNo(value));
- } else if (STRICT_SYNTAX_KEY_SNAKE_CASE.equals(name) || STRICT_SYNTAX_KEY_CAMEL_CASE.equals(name)) {
- setStrictSyntaxMode(StringUtil.getYesNo(value));
} else if (WHITESPACE_STRIPPING_KEY_SNAKE_CASE.equals(name)
|| WHITESPACE_STRIPPING_KEY_CAMEL_CASE.equals(name)) {
setWhitespaceStripping(StringUtil.getYesNo(value));
@@ -3054,6 +3011,14 @@ public class Configuration extends Configurable implements Cloneable, ParserConf
}
@Override
+ protected Version getRemovalVersionForUnknownSetting(String name) {
+ if (name.equals("strictSyntax") || name.equals("strict_syntax")) {
+ return Configuration.VERSION_3_0_0;
+ }
+ return super.getRemovalVersionForUnknownSetting(name);
+ }
+
+ @Override
protected String getCorrectedNameForUnknownSetting(String name) {
if ("encoding".equals(name) || "charset".equals(name) || "default_charset".equals(name)) {
// [2.4] Default might changes to camel-case
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/main/javacc/FTL.jj
----------------------------------------------------------------------
diff --git a/src/main/javacc/FTL.jj b/src/main/javacc/FTL.jj
index 46e565a..077c528 100644
--- a/src/main/javacc/FTL.jj
+++ b/src/main/javacc/FTL.jj
@@ -95,90 +95,6 @@ public class FMParser {
private int mixedContentNesting; // for stripText
/**
- * Create an FM expression parser using a string.
- *
- * @Deprecated This is an internal API of FreeMarker; can be removed any time.
- */
- static public FMParser createExpressionParser(String s) {
- SimpleCharStream scs = new SimpleCharStream(new StringReader(s), 1, 1, s.length());
- FMParserTokenManager token_source = new FMParserTokenManager(scs);
- token_source.SwitchTo(FMParserConstants.FM_EXPRESSION);
- FMParser parser = new FMParser(token_source);
- token_source.setParser(parser);
- return parser;
- }
-
- /**
- * Constructs a new parser object.
- *
- * @param template
- * The template associated with this parser.
- * @param reader
- * The character stream to use as input
- * @param strictEscapeSyntax
- * Whether FreeMarker directives must start with a #
- *
- * @Deprecated This is an internal API of FreeMarker; will be removed in 2.4.
- */
- public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace) {
- this(template, reader, strictEscapeSyntax, stripWhitespace, Configuration.AUTO_DETECT_TAG_SYNTAX);
- }
-
- /**
- * @Deprecated This is an internal API of FreeMarker; will be changed in 2.4.
- */
- public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace, int tagSyntax) {
- this(template, reader, strictEscapeSyntax, stripWhitespace, tagSyntax,
- Configuration.PARSED_DEFAULT_INCOMPATIBLE_ENHANCEMENTS);
- }
-
- /**
- * @Deprecated This is an internal API of FreeMarker; will be changed in 2.4.
- */
- public FMParser(Template template, Reader reader, boolean strictEscapeSyntax, boolean stripWhitespace,
- int tagSyntax, int incompatibleImprovements) {
- this(template, reader, strictEscapeSyntax, stripWhitespace,
- tagSyntax, Configuration.AUTO_DETECT_NAMING_CONVENTION, incompatibleImprovements);
- }
-
- /**
- * @Deprecated This is an internal API of FreeMarker; will be changed in 2.4.
- */
- public FMParser(String template) {
- this(dummyTemplate(),
- new StringReader(template), true, true);
- }
-
- private static Template dummyTemplate() {
- try {
- return new Template(null, new StringReader(""), Configuration.getDefaultConfiguration());
- } catch (IOException e) {
- throw new RuntimeException("Failed to create dummy template", e);
- }
- }
-
- /**
- * @Deprecated This is an internal API of FreeMarker; will be changed in 2.4.
- */
- public FMParser(Template template, Reader reader, boolean strictSyntaxMode, boolean whitespaceStripping,
- int tagSyntax, int namingConvention, int incompatibleImprovements) {
- this(template, reader,
- new LegacyConstructorParserConfiguration(
- strictSyntaxMode, whitespaceStripping,
- tagSyntax, namingConvention,
- template != null ? template.getParserConfiguration().getAutoEscapingPolicy()
- : Configuration.ENABLE_IF_DEFAULT_AUTO_ESCAPING_POLICY,
- template != null ? template.getParserConfiguration().getOutputFormat()
- : null,
- template != null ? template.getParserConfiguration().getRecognizeStandardFileExtensions()
- : null,
- template != null ? template.getParserConfiguration().getTabSize()
- : null,
- new Version(incompatibleImprovements),
- template != null ? template.getArithmeticEngine() : null));
- }
-
- /**
* @Deprecated This is an internal API of FreeMarker; don't call it from outside FreeMarker.
*
* @since 2.3.24
@@ -207,18 +123,6 @@ public class FMParser {
NullArgumentException.check(template);
this.template = template;
- // Hack due to legacy public constructors (removed in 2.4):
- if (pCfg instanceof LegacyConstructorParserConfiguration) {
- LegacyConstructorParserConfiguration lpCfg = (LegacyConstructorParserConfiguration) pCfg;
- lpCfg.setArithmeticEngineIfNotSet(template.getArithmeticEngine());
- lpCfg.setAutoEscapingPolicyIfNotSet(template.getConfiguration().getAutoEscapingPolicy());
- lpCfg.setOutputFormatIfNotSet(template.getOutputFormat());
- lpCfg.setRecognizeStandardFileExtensionsIfNotSet(
- template.getParserConfiguration().getRecognizeStandardFileExtensions());
- lpCfg.setTabSizeIfNotSet(
- template.getParserConfiguration().getTabSize());
- }
-
int incompatibleImprovements = pCfg.getIncompatibleImprovements().intValue();
token_source.incompatibleImprovements = incompatibleImprovements;
this.incompatibleImprovements = incompatibleImprovements;
@@ -239,8 +143,6 @@ public class FMParser {
token_source.setParser(this);
- token_source.strictEscapeSyntax = pCfg.getStrictSyntaxMode();
-
int tagSyntax = pCfg.getTagSyntax();
switch (tagSyntax) {
case Configuration.AUTO_DETECT_TAG_SYNTAX:
@@ -608,8 +510,7 @@ TOKEN_MGR_DECLS:
private int parenthesisNesting;
private int bracketNesting;
private boolean inFTLHeader;
- boolean strictEscapeSyntax,
- squBracTagSyntax,
+ boolean squBracTagSyntax,
autodetectTagSyntax,
directiveSyntaxEstablished,
inInvocation;
@@ -622,22 +523,13 @@ TOKEN_MGR_DECLS:
this.parser = parser;
}
- // This method checks if we are in a strict mode where all
- // FreeMarker directives must start with <#. It also handles
- // tag syntax detection. If you update this logic, take a look
- // at the UNKNOWN_DIRECTIVE token too.
- private void strictSyntaxCheck(Token tok, int tokenNamingConvention, int newLexState) {
+ /**
+ * This method handles tag syntax ('<' VS '['), and also participates in naming convention detection.
+ * If you update this logic, take a look at the UNKNOWN_DIRECTIVE token too.
+ */
+ private void handleTagSyntaxAndSwitch(Token tok, int tokenNamingConvention, int newLexState) {
final String image = tok.image;
- // Non-strict syntax (deprecated) only supports legacy naming convention.
- // We didn't push this on the tokenizer because it made it slow, so we filter here.
- if (!strictEscapeSyntax
- && (tokenNamingConvention == Configuration.CAMEL_CASE_NAMING_CONVENTION)
- && !isStrictTag(image)) {
- tok.kind = STATIC_TEXT_NON_WS;
- return;
- }
-
char firstChar = image.charAt(0);
if (autodetectTagSyntax && !directiveSyntaxEstablished) {
squBracTagSyntax = (firstChar == '[');
@@ -647,23 +539,6 @@ TOKEN_MGR_DECLS:
return;
}
- if (!strictEscapeSyntax) {
- // Legacy feature (or bug?): Tag syntax never gets estabilished in non-strict mode.
- // We do establilish the naming convention though.
- checkNamingConvention(tok, tokenNamingConvention);
- SwitchTo(newLexState);
- return;
- }
-
- // For square bracket tags there's no non-strict token, so we are sure that it's an FTL tag.
- // But if it's an angle bracket tag, we have to check if it's just static text or and FTL tag, because the
- // tokenizer will emit the same kind of token for both.
- if (!squBracTagSyntax && !isStrictTag(image)) {
- tok.kind = STATIC_TEXT_NON_WS;
- return;
- }
-
- // We only get here if this is a strict FTL tag.
directiveSyntaxEstablished = true;
checkNamingConvention(tok, tokenNamingConvention);
@@ -671,6 +546,13 @@ TOKEN_MGR_DECLS:
SwitchTo(newLexState);
}
+ /**
+ * Used for tags whose name isn't affected by naming convention.
+ */
+ private void handleTagSyntaxAndSwitch(Token tok, int newLexState) {
+ handleTagSyntaxAndSwitch(tok, Configuration.AUTO_DETECT_NAMING_CONVENTION, newLexState);
+ }
+
void checkNamingConvention(Token tok) {
checkNamingConvention(tok, _CoreStringUtils.getIdentifierNamingConvention(tok.image));
}
@@ -713,17 +595,6 @@ TOKEN_MGR_DECLS:
}
/**
- * Used for tags whose name isn't affected by naming convention.
- */
- private void strictSyntaxCheck(Token tok, int newLexState) {
- strictSyntaxCheck(tok, Configuration.AUTO_DETECT_NAMING_CONVENTION, newLexState);
- }
-
- private boolean isStrictTag(String image) {
- return image.length() > 2 && (image.charAt(1) == '#' || image.charAt(2) == '#');
- }
-
- /**
* Detects the naming convention used, both in start- and end-tag tokens.
*
* @param charIdxInName
@@ -875,9 +746,9 @@ TOKEN:
{
<#BLANK : " " | "\t" | "\n" | "\r">
|
- <#START_TAG : "<" | "<#" | "[#">
+ <#START_TAG : "<#" | "[#">
|
- <#END_TAG : "</" | "</#" | "[/#">
+ <#END_TAG : "</#" | "[/#">
|
<#CLOSE_TAG1 : (<BLANK>)* (">" | "]")>
|
@@ -886,166 +757,166 @@ TOKEN:
/*
* ATTENTION: Update _CoreAPI.*_BUILT_IN_DIRECTIVE_NAMES if you add new directives!
*/
- <ATTEMPT : <START_TAG> "attempt" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <ATTEMPT : <START_TAG> "attempt" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <RECOVER : <START_TAG> "recover" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <RECOVER : <START_TAG> "recover" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <IF : <START_TAG> "if" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <IF : <START_TAG> "if" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
<ELSE_IF : <START_TAG> "else" ("i" | "I") "f" <BLANK>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 4), FM_EXPRESSION);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 4), FM_EXPRESSION);
}
|
- <LIST : <START_TAG> "list" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <LIST : <START_TAG> "list" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <ITEMS : <START_TAG> "items" (<BLANK>)+ <AS> <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <ITEMS : <START_TAG> "items" (<BLANK>)+ <AS> <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
<SEP : <START_TAG> "sep" <CLOSE_TAG1>>
|
<FOREACH : <START_TAG> "for" ("e" | "E") "ach" <BLANK>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 3), FM_EXPRESSION);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), FM_EXPRESSION);
}
|
- <SWITCH : <START_TAG> "switch" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <SWITCH : <START_TAG> "switch" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <CASE : <START_TAG> "case" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <CASE : <START_TAG> "case" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <ASSIGN : <START_TAG> "assign" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <ASSIGN : <START_TAG> "assign" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <GLOBALASSIGN : <START_TAG> "global" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <GLOBALASSIGN : <START_TAG> "global" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <LOCALASSIGN : <START_TAG> "local" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <LOCALASSIGN : <START_TAG> "local" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <_INCLUDE : <START_TAG> "include" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <_INCLUDE : <START_TAG> "include" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <IMPORT : <START_TAG> "import" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <IMPORT : <START_TAG> "import" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <FUNCTION : <START_TAG> "function" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <FUNCTION : <START_TAG> "function" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <MACRO : <START_TAG> "macro" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <MACRO : <START_TAG> "macro" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <TRANSFORM : <START_TAG> "transform" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <TRANSFORM : <START_TAG> "transform" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <VISIT : <START_TAG> "visit" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <VISIT : <START_TAG> "visit" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <STOP : <START_TAG> "stop" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <STOP : <START_TAG> "stop" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <RETURN : <START_TAG> "return" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <RETURN : <START_TAG> "return" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <CALL : <START_TAG> "call" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <CALL : <START_TAG> "call" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <SETTING : <START_TAG> "setting" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <SETTING : <START_TAG> "setting" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
<OUTPUTFORMAT : <START_TAG> "output" ("f"|"F") "ormat" <BLANK>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 6), FM_EXPRESSION);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 6), FM_EXPRESSION);
}
|
<AUTOESC : <START_TAG> "auto" ("e"|"E") "sc" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 4), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 4), DEFAULT);
}
|
<NOAUTOESC : <START_TAG> "no" ("autoe"|"AutoE") "sc" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
}
|
- <COMPRESS : <START_TAG> "compress" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <COMPRESS : <START_TAG> "compress" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
<COMMENT : <START_TAG> "comment" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, NO_PARSE); noparseTag = "comment";
+ handleTagSyntaxAndSwitch(matchedToken, NO_PARSE); noparseTag = "comment";
}
|
- <TERSE_COMMENT : ("<" | "[") "#--" > { noparseTag = "-->"; strictSyntaxCheck(matchedToken, NO_PARSE); }
+ <TERSE_COMMENT : ("<" | "[") "#--" > { noparseTag = "-->"; handleTagSyntaxAndSwitch(matchedToken, NO_PARSE); }
|
<NOPARSE: <START_TAG> "no" ("p" | "P") "arse" <CLOSE_TAG1>> {
int tagNamingConvention = getTagNamingConvention(matchedToken, 2);
- strictSyntaxCheck(matchedToken, tagNamingConvention, NO_PARSE);
+ handleTagSyntaxAndSwitch(matchedToken, tagNamingConvention, NO_PARSE);
noparseTag = tagNamingConvention == Configuration.CAMEL_CASE_NAMING_CONVENTION ? "noParse" : "noparse";
}
|
- <END_IF : <END_TAG> "if" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_IF : <END_TAG> "if" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_LIST : <END_TAG> "list" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_LIST : <END_TAG> "list" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_ITEMS : <END_TAG> "items" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_ITEMS : <END_TAG> "items" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_SEP : <END_TAG> "sep" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_SEP : <END_TAG> "sep" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_RECOVER : <END_TAG> "recover" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_RECOVER : <END_TAG> "recover" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_ATTEMPT : <END_TAG> "attempt" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_ATTEMPT : <END_TAG> "attempt" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
<END_FOREACH : <END_TAG> "for" ("e" | "E") "ach" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 3), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), DEFAULT);
}
|
- <END_LOCAL : <END_TAG> "local" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_LOCAL : <END_TAG> "local" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_GLOBAL : <END_TAG> "global" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_GLOBAL : <END_TAG> "global" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_ASSIGN : <END_TAG> "assign" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_ASSIGN : <END_TAG> "assign" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_FUNCTION : <END_TAG> "function" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_FUNCTION : <END_TAG> "function" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_MACRO : <END_TAG> "macro" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_MACRO : <END_TAG> "macro" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
<END_OUTPUTFORMAT : <END_TAG> "output" ("f" | "F") "ormat" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 6), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 6), DEFAULT);
}
|
<END_AUTOESC : <END_TAG> "auto" ("e" | "E") "sc" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 4), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 4), DEFAULT);
}
|
<END_NOAUTOESC : <END_TAG> "no" ("autoe"|"AutoE") "sc" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
}
|
- <END_COMPRESS : <END_TAG> "compress" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_COMPRESS : <END_TAG> "compress" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_TRANSFORM : <END_TAG> "transform" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_TRANSFORM : <END_TAG> "transform" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <END_SWITCH : <END_TAG> "switch" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_SWITCH : <END_TAG> "switch" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <ELSE : <START_TAG> "else" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <ELSE : <START_TAG> "else" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <BREAK : <START_TAG> "break" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <BREAK : <START_TAG> "break" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <SIMPLE_RETURN : <START_TAG> "return" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <SIMPLE_RETURN : <START_TAG> "return" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <HALT : <START_TAG> "stop" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <HALT : <START_TAG> "stop" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <FLUSH : <START_TAG> "flush" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <FLUSH : <START_TAG> "flush" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <TRIM : <START_TAG> "t" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <TRIM : <START_TAG> "t" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <LTRIM : <START_TAG> "lt" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <LTRIM : <START_TAG> "lt" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <RTRIM : <START_TAG> "rt" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <RTRIM : <START_TAG> "rt" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <NOTRIM : <START_TAG> "nt" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <NOTRIM : <START_TAG> "nt" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <DEFAUL : <START_TAG> "default" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <DEFAUL : <START_TAG> "default" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <SIMPLE_NESTED : <START_TAG> "nested" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <SIMPLE_NESTED : <START_TAG> "nested" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <NESTED : <START_TAG> "nested" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <NESTED : <START_TAG> "nested" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <SIMPLE_RECURSE : <START_TAG> "recurse" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <SIMPLE_RECURSE : <START_TAG> "recurse" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <RECURSE : <START_TAG> "recurse" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <RECURSE : <START_TAG> "recurse" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <FALLBACK : <START_TAG> "fallback" <CLOSE_TAG2>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <FALLBACK : <START_TAG> "fallback" <CLOSE_TAG2>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
- <ESCAPE : <START_TAG> "escape" <BLANK>> { strictSyntaxCheck(matchedToken, FM_EXPRESSION); }
+ <ESCAPE : <START_TAG> "escape" <BLANK>> { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
|
- <END_ESCAPE : <END_TAG> "escape" <CLOSE_TAG1>> { strictSyntaxCheck(matchedToken, DEFAULT); }
+ <END_ESCAPE : <END_TAG> "escape" <CLOSE_TAG1>> { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); }
|
<NOESCAPE : <START_TAG> "no" ("e" | "E") "scape" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
}
|
<END_NOESCAPE : <END_TAG> "no" ("e" | "E") "scape" <CLOSE_TAG1>> {
- strictSyntaxCheck(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
+ handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 2), DEFAULT);
}
|
<UNIFIED_CALL : "<@" | "[@" > { unifiedCall(matchedToken); }
@@ -1075,7 +946,7 @@ TOKEN:
matchedToken.kind = STATIC_TEXT_NON_WS;
} else if (firstChar == '[' && !squBracTagSyntax) {
matchedToken.kind = STATIC_TEXT_NON_WS;
- } else if (strictEscapeSyntax) {
+ } else {
String dn = matchedToken.image;
int index = dn.indexOf('#');
dn = dn.substring(index + 1);
@@ -1538,8 +1409,7 @@ TOKEN:
|
<MAYBE_END :
("<" | "[")
- "/"
- ("#")?
+ "/#"
(["a"-"z", "A"-"Z"])+
( " " | "\t" | "\n" | "\r" )*
(">" | "]")
@@ -4197,8 +4067,6 @@ void HeaderElement() :
this.stripWhitespace = getBoolean(exp, true);
} else if (ks.equalsIgnoreCase("STRIP_TEXT") || ks.equals("stripText")) {
this.stripText = getBoolean(exp, true);
- } else if (ks.equalsIgnoreCase("STRICT_SYNTAX") || ks.equals("strictSyntax")) {
- this.token_source.strictEscapeSyntax = getBoolean(exp, true);
} else if (ks.equalsIgnoreCase("auto_esc") || ks.equals("autoEsc")) {
if (getBoolean(exp, false)) {
autoEscRequester = key;
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/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 43ad129..d5d6868 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -13,4 +13,7 @@ the FreeMarer 3 changelog here:
- Removed utility TemplateModel-s that can very easily mean a security problem: freemarker.template.utility.Execute and
freemarker.template.utility.ObjectConstructor
- Removed TemplateClassResolver.SAFER_RESOLVER, because the classes it has blocked were removed from FreeMarker, so it's
- the same as UNRESTRICTED_RESOLVER
\ No newline at end of file
+ the same as UNRESTRICTED_RESOLVER
+- Removed the strict_syntax setting, and so also the support for FTL tags without #. This was a FreeMarker 1.x
+ compatibility option.
+- Removed deprecated FMParser contstructors.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/java/freemarker/core/CamelCaseTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/CamelCaseTest.java b/src/test/java/freemarker/core/CamelCaseTest.java
index 16232c1..5698804 100644
--- a/src/test/java/freemarker/core/CamelCaseTest.java
+++ b/src/test/java/freemarker/core/CamelCaseTest.java
@@ -18,7 +18,8 @@
*/
package freemarker.core;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Arrays;
@@ -88,7 +89,6 @@ public class CamelCaseTest extends TemplateTest {
"<#ftl "
+ "stripWhitespace=false "
+ "stripText=true "
- + "strictSyntax=true "
+ "outputFormat='" + HTMLOutputFormat.INSTANCE.getName() + "' "
+ "autoEsc=true "
+ "nsPrefixes={} "
@@ -99,7 +99,6 @@ public class CamelCaseTest extends TemplateTest {
"<#ftl "
+ "strip_whitespace=false "
+ "strip_text=true "
- + "strict_syntax=true "
+ "output_format='" + HTMLOutputFormat.INSTANCE.getName() + "' "
+ "auto_esc=true "
+ "ns_prefixes={} "
@@ -160,7 +159,8 @@ public class CamelCaseTest extends TemplateTest {
public void specialVarsHasBothNamingStyle() throws IOException, TemplateException {
assertContainsBothNamingStyles(
new HashSet(Arrays.asList(BuiltinVariable.SPEC_VAR_NAMES)),
- new NamePairAssertion() { public void assertPair(String name1, String name2) { } });
+ new NamePairAssertion() { @Override
+ public void assertPair(String name1, String name2) { } });
}
@Test
@@ -255,9 +255,10 @@ public class CamelCaseTest extends TemplateTest {
public void builtInsHasBothNamingStyle() throws IOException, TemplateException {
assertContainsBothNamingStyles(getConfiguration().getSupportedBuiltInNames(), new NamePairAssertion() {
+ @Override
public void assertPair(String name1, String name2) {
- BuiltIn bi1 = (BuiltIn) BuiltIn.BUILT_INS_BY_NAME.get(name1);
- BuiltIn bi2 = (BuiltIn) BuiltIn.BUILT_INS_BY_NAME.get(name2);
+ BuiltIn bi1 = BuiltIn.BUILT_INS_BY_NAME.get(name1);
+ BuiltIn bi2 = BuiltIn.BUILT_INS_BY_NAME.get(name2);
assertTrue("\"" + name1 + "\" and \"" + name2 + "\" doesn't belong to the same BI object.",
bi1 == bi2);
}
@@ -289,34 +290,6 @@ public class CamelCaseTest extends TemplateTest {
private String correctIsoBIExceptions(String underscoredName) {
return underscoredName.replace("_n_z", "_nz").replace("_f_z", "_fz");
}
-
- @Test
- public void camelCaseDirectivesNonStrict() throws IOException, TemplateException {
- getConfiguration().setStrictSyntaxMode(false);
-
- assertOutput(
- "<list 1..4 as x><if x == 1>one <elseIf x == 2>two <elseif x == 3>three <else>other </if></list>",
- "one <elseIf x == 2>two other three other ");
- assertOutput(
- "<escape x as x?upper_case>${'a'}<noEscape>${'b'}</noEscape></escape> "
- + "<escape x as x?upper_case>${'a'}<noescape>${'b'}</noescape></escape>",
- "A<noEscape>B</noEscape> Ab");
- assertOutput(
- "<noParse>${1}</noParse> <noparse>${1}</noparse>",
- "<noParse>1</noParse> ${1}");
- assertOutput(
- "<forEach x in 1..3>${x!'?'}</forEach> <foreach x in 1..3>${x}</foreach>",
- "<forEach x in 1..3>?</forEach> 123");
-
- assertOutput("<foreach x in 1..3>${x}</foreach> <#foreach x in 1..3>${x}</#foreach>",
- "123 123");
- assertErrorContains("<foreach x in 1..3>${x}</foreach> <#forEach x in 1..3>${x}</#forEach>",
- "naming convention", "legacy", "#forEach");
- assertErrorContains("<#forEach x in 1..3>${x}</#forEach> <foreach x in 1..3>${x}</foreach>",
- "naming convention", "camel", "foreach");
-
- camelCaseDirectives();
- }
@Test
public void camelCaseDirectives() throws IOException, TemplateException {
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/java/freemarker/core/LegacyFMParserConstructorsTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/LegacyFMParserConstructorsTest.java b/src/test/java/freemarker/core/LegacyFMParserConstructorsTest.java
deleted file mode 100644
index 738d227..0000000
--- a/src/test/java/freemarker/core/LegacyFMParserConstructorsTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import org.junit.Test;
-
-public class LegacyFMParserConstructorsTest {
-
- @Test
- public void test1() throws ParseException {
- FMParser parser = new FMParser("x");
- parser.Root();
- }
-
- @Test
- public void testCreateExpressionParser() throws ParseException {
- FMParser parser = FMParser.createExpressionParser("x + y");
- parser.Expression();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/java/freemarker/core/TemplateConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/TemplateConfigurationTest.java b/src/test/java/freemarker/core/TemplateConfigurationTest.java
index 5392af0..9bdb7c2 100644
--- a/src/test/java/freemarker/core/TemplateConfigurationTest.java
+++ b/src/test/java/freemarker/core/TemplateConfigurationTest.java
@@ -649,14 +649,6 @@ public class TemplateConfigurationTest {
{
TemplateConfiguration tc = new TemplateConfiguration();
- tc.setParentConfiguration(DEFAULT_CFG);
- tc.setStrictSyntaxMode(false);
- assertOutputWithoutAndWithTC(tc, "<if true>y</if>", "<if true>y</if>", "y");
- testedProps.add("strictSyntaxMode");
- }
-
- {
- TemplateConfiguration tc = new TemplateConfiguration();
tc.setParentConfiguration(new Configuration(new Version(2, 3, 0)));
assertOutputWithoutAndWithTC(tc, "<#foo>", null, "<#foo>");
testedProps.add(Configuration.INCOMPATIBLE_IMPROVEMENTS_KEY_CAMEL_CASE);
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/java/freemarker/template/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/template/ConfigurationTest.java b/src/test/java/freemarker/template/ConfigurationTest.java
index cdd4d9e..58b8724 100644
--- a/src/test/java/freemarker/template/ConfigurationTest.java
+++ b/src/test/java/freemarker/template/ConfigurationTest.java
@@ -1770,10 +1770,16 @@ public class ConfigurationTest extends TestCase {
}
@Test
- public void testClassicCompatibleRemoved() {
+ public void testRemovedSettings() {
Configuration cfg = new Configuration();
try {
- cfg.setSetting("classicCompatible", "true");
+ cfg.setSetting("classic_compatible", "true");
+ fail();
+ } catch (TemplateException e) {
+ assertThat(e.getMessage(), allOf(containsString("removed"), containsString("3.0.0")));
+ }
+ try {
+ cfg.setSetting("strict_syntax", "true");
fail();
} catch (TemplateException e) {
assertThat(e.getMessage(), allOf(containsString("removed"), containsString("3.0.0")));
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/expected/non-strict-syntax.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/non-strict-syntax.txt b/src/test/resources/freemarker/test/templatesuite/expected/non-strict-syntax.txt
deleted file mode 100644
index 75e0b45..0000000
--- a/src/test/resources/freemarker/test/templatesuite/expected/non-strict-syntax.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-<html>
-<head>
-<title>FreeMarker: Identifier Test</title>
-</head>
-<body>
-<p>A simple test follows:</p>
-
-<p>Hello, world!</p>
-
-<p>A tag inside a tag...</p>
-
-<i>this is a test</i>
-
-<if>Blah</if>
-<ifthisisindeedworkingthisshouldnotparseasafreemarkertag>
-
-<b>This is a test</b>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/expected/noparse.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/noparse.txt b/src/test/resources/freemarker/test/templatesuite/expected/noparse.txt
index d6272ac..451240a 100644
--- a/src/test/resources/freemarker/test/templatesuite/expected/noparse.txt
+++ b/src/test/resources/freemarker/test/templatesuite/expected/noparse.txt
@@ -32,9 +32,9 @@ ${message@#$%&}
<p>Message exists!
...and even generates output!
- <if message>
+ <#if message>
Nested statements are ok, too.
- </if>
+ </#if>
</p>
Here's another edge case, this time, trying to output a <noparse>
@@ -43,9 +43,9 @@ inside another <noparse>
This is what the noparse instruction looks like:
-<noparse>This part of the template wont be parsed by the
+<#noparse>This part of the template wont be parsed by the
FreeMarker parser. Instead, it will be treated as verbatim text information,
-and output as such.</noparse>
+and output as such.</#noparse>
The rest of the template appears here.
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/expected/strictinheader.txt
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/expected/strictinheader.txt b/src/test/resources/freemarker/test/templatesuite/expected/strictinheader.txt
deleted file mode 100644
index 893cb63..0000000
--- a/src/test/resources/freemarker/test/templatesuite/expected/strictinheader.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-1
-<include "test1.ftl">
-34
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/comment.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/comment.ftl b/src/test/resources/freemarker/test/templatesuite/templates/comment.ftl
index 7bf18b9..973c993 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/comment.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/comment.ftl
@@ -1,4 +1,3 @@
-<#ftl strict_syntax=false>
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -32,17 +31,17 @@ A more rigorous test, showing that we're not faking it:
${message@#$%&}
---><#-- > --><#-- -> --><#-- -- --><#-- -- > --><comment> > </comment><comment> </comment </comment>
-<if message?exists>
+--><#-- > --><#-- -> --><#-- -- --><#-- -- > --><#comment> > </#comment><#comment> </#comment </#comment>
+<#if message?exists>
<p>Message exists!
- <comment>
+ <#comment>
...and even generates output!
- </comment>
+ </#comment>
</p>
-</if>
+</#if>
a <#-- < --> b
-a <#-- </comment> - -- --> b
+a <#-- </#comment> - -- --> b
${1 + 2 + [#-- c --] <#-- c --> <!-- c --> 3}
${<!-- > -> -- #> #] --> 7}
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/macros.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/macros.ftl b/src/test/resources/freemarker/test/templatesuite/templates/macros.ftl
index e305985..90a36f9 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/macros.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/macros.ftl
@@ -1,4 +1,3 @@
-<#ftl strict_syntax="false">
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -32,21 +31,21 @@
<#assign urls = {"home" : "/home.html", "about" : "/about.html"}>
<#assign images = {"home" : "/images/home.png", "about" : "/image/about-us.jpeg"}>
<#assign preferences = {"showImages" : true}>
-<assign "espa�ol" = fran�ais><#macro fran�ais(url, image, alt)>
- <local var = "Kilroy">
+<#assign "espa�ol" = fran�ais><#macro fran�ais(url, image, alt)>
+ <#local var = "Kilroy">
<a href="${url}">
- <if preferences.showImages>
+ <#if preferences.showImages>
<img src="${image}" border="0" alt="${alt}">
- <else>
+ <#else>
${alt}
- </if>
+ </#if>
</a>
${var} was here.
</#macro>
<p>Function is defined, now let's call it:</p>
- <call espa�ol(urls.home, images.home, "Home")><#t>
+ <@espa�ol urls.home images.home "Home" /><#t>
<p>Again, but with different parameters:</p>
@@ -58,18 +57,18 @@
<#if var?exists>
Something is wrong here.
-<else>
+<#else>
Good.
</#if>
<p>A recursive function call:</p>
-<macro recurse(dummy, a=3)>
- <if (a > 0)>
- <call recurse(dummy, a - 1)>
- </if>
+<#macro recurse(dummy, a=3)>
+ <#if (a > 0)>
+ <@recurse dummy a - 1 />
+ </#if>
${a}
-</macro>
+</#macro>
<@recurse urls />
@@ -96,7 +95,7 @@ foo=${foo} baz=[<#list bar?keys?sort as key>${key}=${bar[key]}<#if key_has_next>
<@assertFails message='"c"'><@m c=3 /></@>
<@assertFails message='3'><@m 9 8 7 /></@>
-<call fmt("Hello {0}! Today is {1}.", "World", "Monday")>
+<@fmt "Hello {0}! Today is {1}.", "World", "Monday" />
</body>
</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/non-strict-syntax.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/non-strict-syntax.ftl b/src/test/resources/freemarker/test/templatesuite/templates/non-strict-syntax.ftl
deleted file mode 100644
index 0ff029b..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/non-strict-syntax.ftl
+++ /dev/null
@@ -1,38 +0,0 @@
-<#--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<html>
-<head>
-<title>FreeMarker: Identifier Test</title>
-</head>
-<body>
-<p>A simple test follows:</p>
-
-<p>${message}</p>
-
-<p>A tag inside a tag...</p>
-
-<#assign f="f">
-<i<if message?exists>>this is a test<else>>no message</if></i>
-
-<i${f}>Blah</i${f}>
-<ifthisisindeedworkingthisshouldnotparseasafreemarkertag>
-
-<<if message?exists>b>This is a test</b<else>strong>no message</strong</if>>
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/noparse.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/noparse.ftl b/src/test/resources/freemarker/test/templatesuite/templates/noparse.ftl
index ea36801..962ef7b 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/noparse.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/noparse.ftl
@@ -1,4 +1,3 @@
-<#ftl strict_syntax=false>
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -22,7 +21,7 @@
<title>FreeMarker: NoParse Test</title>
</head>
<body>
-<noparse>
+<#noparse>
A simple test follows:
@@ -32,31 +31,31 @@ A more rigorous test, showing that we're not faking it:
${message@#$%&}
-</noparse>
-<if message?exists>
+</#noparse>
+<#if message?exists>
<p>Message exists!
- <noparse>
+ <#noparse>
...and even generates output!
- <if message>
+ <#if message>
Nested statements are ok, too.
- </if>
- </noparse>
+ </#if>
+ </#noparse>
</p>
-</if>
+</#if>
Here's another edge case, this time, trying to output a <noparse>
inside another <noparse>
-<noparse>
+<#noparse>
This is what the noparse instruction looks like:
-<nop</noparse><noparse>arse>This part of the template wont be parsed by the
+<#nop</#noparse><#noparse>arse>This part of the template wont be parsed by the
FreeMarker parser. Instead, it will be treated as verbatim text information,
-and output as such.</nop</noparse><noparse>arse>
+and output as such.</#nop</#noparse><#noparse>arse>
The rest of the template appears here.
-</noparse>
+</#noparse>
Simple.
</body>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/root.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/root.ftl b/src/test/resources/freemarker/test/templatesuite/templates/root.ftl
index 8deb77c..8a7e3c5 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/root.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/root.ftl
@@ -1,4 +1,3 @@
-<#ftl strict_syntax=false>
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -37,12 +36,12 @@
<p>Ensure that root lookups are unaffected by local variables:</p>
-<macro test(message)>
+<#macro test message>
${.data_model.message}
${message}
-</macro>
+</#macro>
-<call test(message + " Part Deux")>
+<@test message + " Part Deux" />
</body>
</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/strictinheader.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/strictinheader.ftl b/src/test/resources/freemarker/test/templatesuite/templates/strictinheader.ftl
deleted file mode 100644
index bf4678a..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/strictinheader.ftl
+++ /dev/null
@@ -1,23 +0,0 @@
-<#ftl strict_syntax="yes">
-<#--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-1
-<include "test1.ftl">
-<#include "strictinheader_inc1.ftl">
-<#include "strictinheader_inc2.ftl">
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc1.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc1.ftl b/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc1.ftl
deleted file mode 100644
index 0c2111c..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc1.ftl
+++ /dev/null
@@ -1,21 +0,0 @@
-<#ftl strict_syntax="no">
-<#--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<global x = 3>
-${x}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc2.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc2.ftl b/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc2.ftl
deleted file mode 100644
index 1720945..0000000
--- a/src/test/resources/freemarker/test/templatesuite/templates/strictinheader_inc2.ftl
+++ /dev/null
@@ -1,20 +0,0 @@
-<#--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<global x = 4>
-${x}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/templates/transforms.ftl
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/templates/transforms.ftl b/src/test/resources/freemarker/test/templatesuite/templates/transforms.ftl
index e1f6ee1..a4474a0 100644
--- a/src/test/resources/freemarker/test/templatesuite/templates/transforms.ftl
+++ b/src/test/resources/freemarker/test/templatesuite/templates/transforms.ftl
@@ -1,4 +1,3 @@
-<#ftl strict_syntax=false>
<#--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -36,66 +35,66 @@
<P>Now try the Utility package:</p>
<p>${utility}</p>
-<transform utility.htmlEscape>
+<@utility.htmlEscape>
<p>${utility}</p>
-</transform>
+</@>
<p>Now some nested transforms:</p>
-<transform utility.compress>
+<@utility.compress>
<p >This tests the compress transformation</p >
-</transform>
+</@>
<@utility.compress>
-<transform utility.htmlEscape>
+<@utility.htmlEscape>
<p >This tests the compress transformation</p >
-</transform>
+</@>
</...@utility.compress>
<#assign html_transform = "freemarker.template.utility.HtmlEscape"?new() />
-<transform html_transform><#--Using the transform via an instantiation -->
-<transform utility.compress>
+<@html_transform><#--Using the transform via an instantiation -->
+<@utility.compress>
<p >This tests the compress transformation</p >
-</transform>
-</transform>
+</@>
+</@>
<p>Now try method and transform interactions:</p>
-<transform utility.escape( "xml" )>
+<@utility.escape("xml")>
<p>This isn't a valid XML string.</p>
-</transform>
-<transform utility.escape( "html" )>
+</@>
+<@utility.escape("html")>
<p>This isn't a valid HTML string.</p>
-</transform>
+</@>
<p>A more advanced interaction involves getting a TemplateMethodModel
to initialise a TemplateTransformModel, as follow:</p>
-<transform utility.special( "This is a comment" )>
+<@utility.special("This is a comment")>
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: <p>Fish & Chips.</p>
-</transform>
+</@>
-<transform utility.special( "This is a second comment", "quote" )>
+<@utility.special("This is a second comment", "quote")>
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: <p>Fish & Chips.</p>
-</transform>
-<transform utility.special( "This is a third comment", "ampersand", "quote" )>
+</@>
+<@utility.special("This is a third comment", "ampersand", "quote")>
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: <p>Fish & Chips.</p>
-</transform>
-<transform utility.special( "tag", utility )>
+</@>
+<@utility.special("tag", utility)>
Comment: *
A test string containing quotes: "This isn't a test".
A test string containing amps: Fish & Chips.
A test string containing tags: <p>Fish & Chips.</p>
-</transform>
+</@>
</body>
</html>
http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/7483146d/src/test/resources/freemarker/test/templatesuite/testcases.xml
----------------------------------------------------------------------
diff --git a/src/test/resources/freemarker/test/templatesuite/testcases.xml b/src/test/resources/freemarker/test/templatesuite/testcases.xml
index a5ba4bf..9e4ce10 100644
--- a/src/test/resources/freemarker/test/templatesuite/testcases.xml
+++ b/src/test/resources/freemarker/test/templatesuite/testcases.xml
@@ -40,7 +40,6 @@
object_wrapper CDATA #IMPLIED
output_encoding CDATA #IMPLIED
output_dir CDATA #IMPLIED
- strict_syntax (Y|N) #IMPLIED
new_builtin_class_resolver CDATA #IMPLIED
url_escaping_charset CDATA #IMPLIED
incompatible_improvements CDATA #IMPLIED
@@ -101,9 +100,6 @@
<testCase name="hashliteral">
<setting incompatible_improvements="min, 2.3.20, 2.3.21, max" />
</testCase>
- <testCase name="non-strict-syntax" >
- <setting strict_syntax="N" />
- </testCase>
<testCase name="identifier-non-ascii" />
<testCase name="identifier-escaping" />
<testCase name="import">
@@ -189,9 +185,6 @@
<setting object_wrapper="freemarker.template.SimpleObjectWrapper"/>
</testCase>
<testCase name="simplehash-char-key" noOutput="true" />
- <testCase name="strictinheader">
- <setting strict_syntax="N"/>
- </testCase>
<testCase name="existence-operators" noOutput="true" />
<testCase name="string-builtins1">
<setting incompatible_improvements="min, 2.3.20, max"/>