freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Removed the `.templateName` (`.template_name`) special variable, which was deprecated by `.currentTemplateName` since 2.3.23.
Date Mon, 17 Jul 2017 10:34:39 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 8a2cf2795 -> 9f5c18a4e


Removed the `.templateName` (`.template_name`) special variable, which was deprecated by `.currentTemplateName`
since 2.3.23.


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

Branch: refs/heads/3
Commit: 9f5c18a4e1e5b2a63caf36494cdb96102c0d2fe2
Parents: 8a2cf27
Author: ddekany <ddekany@apache.org>
Authored: Mon Jul 17 12:34:32 2017 +0200
Committer: ddekany <ddekany@apache.org>
Committed: Mon Jul 17 12:34:32 2017 +0200

----------------------------------------------------------------------
 FM3-CHANGE-LOG.txt                                              | 5 +++++
 .../main/java/freemarker/core/FM2ASTToFM3SourceConverter.java   | 2 ++
 .../java/org/freemarker/converter/FM2ToFM3ConverterTest.java    | 1 +
 .../freemarker/core/templatesuite/templates/specialvars.ftl     | 2 +-
 .../java/org/apache/freemarker/core/ASTExpBuiltInVariable.java  | 5 +----
 5 files changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9f5c18a4/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/FM3-CHANGE-LOG.txt b/FM3-CHANGE-LOG.txt
index 5a51357..68f09c0 100644
--- a/FM3-CHANGE-LOG.txt
+++ b/FM3-CHANGE-LOG.txt
@@ -69,6 +69,11 @@ Node: Changes already mentioned above aren't repeated here!
   `?dateTime` and `?dateTimeIfUnknown` and `dateTimeFormat`. (In general, it's `dateTime`,
not `datetime` everywhere.)
           assertConverted("${.outputFormat}","${.output_format}");
 - Removed the `.currentNode` (`.current_node`) special variable, which was a deprecated alias
to `.node`
+- Removed the `.templateName` (`.template_name`) special variable, which was deprecated by
`.currentTemplateName`
+  since 2.3.23.
+  Converter note: This conversion is done, but note that in the rare case where a template
has no name (when
+  creating a `Template` directly with its constructor using `null` as the `name` parameter)
`.templateName` was an
+  empty string, while `.currentTemplateName` will be null.
 
 
 Java API changes

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9f5c18a4/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java
----------------------------------------------------------------------
diff --git a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java
b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java
index b4b7f99..9ee615e 100644
--- a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java
+++ b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java
@@ -1517,6 +1517,8 @@ public class FM2ASTToFM3SourceConverter {
 
         if (converted.equals("currentNode")) {
             converted = "node";
+        } else if (converted.equals("templateName")) {
+            converted = "currentTemplateName";
         }
 
         return converted;

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9f5c18a4/freemarker-converter/src/test/java/org/freemarker/converter/FM2ToFM3ConverterTest.java
----------------------------------------------------------------------
diff --git a/freemarker-converter/src/test/java/org/freemarker/converter/FM2ToFM3ConverterTest.java
b/freemarker-converter/src/test/java/org/freemarker/converter/FM2ToFM3ConverterTest.java
index 9832d73..5d79962 100644
--- a/freemarker-converter/src/test/java/org/freemarker/converter/FM2ToFM3ConverterTest.java
+++ b/freemarker-converter/src/test/java/org/freemarker/converter/FM2ToFM3ConverterTest.java
@@ -121,6 +121,7 @@ public class FM2ToFM3ConverterTest extends ConverterTest {
         assertConvertedSame("${. <#-- C --> outputFormat}");
         assertConverted("${.outputFormat}","${.output_format}");
         assertConverted("${.node}","${.current_node}");
+        assertConverted("${.currentTemplateName}","${.template_name}");
 
         assertConvertedSame("${a < b}${a <= b}${(a > b)}${(a >= b)}${a == b}${a
!= b}");
         assertConvertedSame("${a<#--1--><<#--2-->b}${a<#--3--><=<#--4-->b}"

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9f5c18a4/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/specialvars.ftl
----------------------------------------------------------------------
diff --git a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/specialvars.ftl
b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/specialvars.ftl
index 3aa2a62..c6b608f 100644
--- a/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/specialvars.ftl
+++ b/freemarker-core-test/src/test/resources/org/apache/freemarker/core/templatesuite/templates/specialvars.ftl
@@ -30,7 +30,7 @@ ${.locale} == en_US
 <#assign works = .main>
 <#assign works = .node!>
 ${.outputEncoding?lowerCase} == utf-8
-${.templateName} == specialvars.ftl
+${.currentTemplateName} == specialvars.ftl
 ${.urlEscapingCharset?lowerCase} == iso-8859-1
 <#assign foo = "x">
 ${.vars['foo']} == x

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/9f5c18a4/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
----------------------------------------------------------------------
diff --git a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
index 343363a..74ae72f 100644
--- a/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
+++ b/freemarker-core/src/main/java/org/apache/freemarker/core/ASTExpBuiltInVariable.java
@@ -37,7 +37,6 @@ import org.apache.freemarker.core.util._StringUtil;
  */
 final class ASTExpBuiltInVariable extends ASTExpression {
 
-    static final String TEMPLATE_NAME = "templateName";
     static final String MAIN_TEMPLATE_NAME = "mainTemplateName";
     static final String CURRENT_TEMPLATE_NAME = "currentTemplateName";
     static final String NAMESPACE = "namespace";
@@ -80,7 +79,6 @@ final class ASTExpBuiltInVariable extends ASTExpression {
         OUTPUT_ENCODING,
         OUTPUT_FORMAT,
         PASS,
-        TEMPLATE_NAME,
         URL_ESCAPING_CHARSET,
         VARS,
         VERSION
@@ -171,8 +169,7 @@ final class ASTExpBuiltInVariable extends ASTExpression {
         if (name == MAIN_TEMPLATE_NAME) {
             return SimpleScalar.newInstanceOrNull(env.getMainTemplate().getLookupName());
         }
-        // [FM3] Some of these two should be removed.
-        if (name == CURRENT_TEMPLATE_NAME || name == TEMPLATE_NAME) {
+        if (name == CURRENT_TEMPLATE_NAME) {
             return SimpleScalar.newInstanceOrNull(env.getCurrentTemplate().getLookupName());
         }
         if (name == PASS) {


Mime
View raw message