freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [21/25] incubator-freemarker git commit: Bug fixed: If the incompatible_improvements setting is set to 2.3.26 (or higher), exp?interpret always gets the parser-related settings from the template that it's called from. Earlier, sometimes it got those from
Date Mon, 13 Mar 2017 10:43:37 GMT
Bug fixed: If the incompatible_improvements setting is set to 2.3.26 (or higher), exp?interpret
always gets the parser-related settings from the template that it's called from. Earlier,
sometimes it got those from the topmost (main) template instead. Similarly, the generated
name of the template that ?interpret creates will always refer to the template where's it's
called from.


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

Branch: refs/heads/2.3
Commit: a863373968a348d2f83872e1637b8c6499bfba50
Parents: 696ca6b
Author: ddekany <ddekany@apache.org>
Authored: Sun Mar 12 17:53:48 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Sun Mar 12 17:53:48 2017 +0100

----------------------------------------------------------------------
 src/main/java/freemarker/core/Interpret.java       |  4 +++-
 src/manual/en_US/book.xml                          | 13 +++++++++++++
 .../core/InterpretAndEvalTemplateNameTest.java     | 17 +++++++++++++++--
 3 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a8633739/src/main/java/freemarker/core/Interpret.java
----------------------------------------------------------------------
diff --git a/src/main/java/freemarker/core/Interpret.java b/src/main/java/freemarker/core/Interpret.java
index 818e7a9..a2cff1c 100644
--- a/src/main/java/freemarker/core/Interpret.java
+++ b/src/main/java/freemarker/core/Interpret.java
@@ -31,6 +31,7 @@ import freemarker.template.TemplateModelException;
 import freemarker.template.TemplateScalarModel;
 import freemarker.template.TemplateSequenceModel;
 import freemarker.template.TemplateTransformModel;
+import freemarker.template._TemplateAPI;
 
 
 /**
@@ -79,7 +80,8 @@ class Interpret extends OutputFormatBoundBuiltIn {
                     env);
         }
         String templateSource = sourceExpr.evalAndCoerceToPlainText(env);
-        Template parentTemplate = env.getTemplate();
+        Template parentTemplate = env.getConfiguration().getIncompatibleImprovements().intValue()
+                >= _TemplateAPI.VERSION_INT_2_3_26 ? env.getCurrentTemplate() : env.getTemplate();
         
         final Template interpretedTemplate;
         try {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a8633739/src/manual/en_US/book.xml
----------------------------------------------------------------------
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index c9248de..741c1a0 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -26895,6 +26895,19 @@ TemplateModel x = env.getVariable("x");  // get variable x</programlisting>
             </listitem>
 
             <listitem>
+              <para>Bug fixed: If <link
+              linkend="pgui_config_incompatible_improvements_how_to_set">the
+              <literal>incompatible_improvements</literal> setting</link>
is
+              set to 2.3.26 (or higher),
+              <literal><replaceable>exp</replaceable>?interpret</literal>
+              always gets the parser-related settings from the template that
+              it's called from. Earlier, sometimes it got those from the
+              topmost (main) template instead. Similarly, the generated name
+              of the template that <literal>?interpret</literal> creates will
+              always refer to the template where's it's called from.</para>
+            </listitem>
+
+            <listitem>
               <para>Bug fixed: <literal>MultiTemplateLoader</literal>,
when
               it's in sticky mode (the default), and the
               <literal>TemplateLoader</literal> that was successfully used for

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a8633739/src/test/java/freemarker/core/InterpretAndEvalTemplateNameTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/freemarker/core/InterpretAndEvalTemplateNameTest.java b/src/test/java/freemarker/core/InterpretAndEvalTemplateNameTest.java
index 6f18c37..7652871 100644
--- a/src/test/java/freemarker/core/InterpretAndEvalTemplateNameTest.java
+++ b/src/test/java/freemarker/core/InterpretAndEvalTemplateNameTest.java
@@ -23,7 +23,9 @@ import java.io.IOException;
 import org.junit.Test;
 
 import freemarker.cache.StringTemplateLoader;
+import freemarker.template.Configuration;
 import freemarker.template.TemplateException;
+import freemarker.template.Version;
 import freemarker.test.TemplateTest;
 
 /**
@@ -31,9 +33,20 @@ import freemarker.test.TemplateTest;
  * {@code ?eval}-ed parts.  
  */
 public class InterpretAndEvalTemplateNameTest extends TemplateTest {
-    
+
     @Test
-    public void testInterpret() throws IOException, TemplateException {
+    public void testInterpret230() throws IOException, TemplateException {
+        testInterpret(Configuration.VERSION_2_3_0);
+    }
+
+    @Test
+    public void testInterpret2326() throws IOException, TemplateException {
+        testInterpret(Configuration.VERSION_2_3_26);
+    }
+    
+    private void testInterpret(Version version) throws IOException, TemplateException {
+        getConfiguration().setIncompatibleImprovements(version);
+        
         for (String getTemplateNames : new String[] {
                 "c=${.current_template_name}, m=${.main_template_name}",
                 "c=${\".current_template_name\"?eval}, m=${\".main_template_name\"?eval}"


Mime
View raw message