velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r737465 - in /velocity/engine/trunk/src: changes/changes.xml java/org/apache/velocity/runtime/directive/Evaluate.java test/org/apache/velocity/test/issues/Velocity682TestCase.java
Date Sun, 25 Jan 2009 01:35:18 GMT
Author: nbubna
Date: Sun Jan 25 01:35:18 2009
New Revision: 737465

URL: http://svn.apache.org/viewvc?rev=737465&view=rev
Log:
VELOCITY-682 don't dump inline macro namespace when #evaluate runs, also stop double wrapping
the context

Modified:
    velocity/engine/trunk/src/changes/changes.xml
    velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Evaluate.java
    velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity682TestCase.java

Modified: velocity/engine/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/changes/changes.xml?rev=737465&r1=737464&r2=737465&view=diff
==============================================================================
--- velocity/engine/trunk/src/changes/changes.xml (original)
+++ velocity/engine/trunk/src/changes/changes.xml Sun Jan 25 01:35:18 2009
@@ -27,12 +27,16 @@
   <body>
     <release version="1.7" date="In Subversion">
 
+      <action type="fix" dev="nbubna" issue="VELOCITY-682">
+        Fix loss of inline macros when #evaluate is used.
+      </action>
+
       <action type="add" dev="byron"  issue="VELOCITY-673">
 	The non default VelocityEngine construtors now do not initialize the runtime
 	system so that properties may be set after constrution.  Also fixes an
 	Initialization race condition.
       </action>
-      
+
       <action type="fix" dev="nbubna" issue="VELOCITY-685" due-to="Jarkko Viinamäki">
         Make velocimacro.arguments.strict=true work with block macros.
       </action>

Modified: velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Evaluate.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Evaluate.java?rev=737465&r1=737464&r2=737465&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Evaluate.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Evaluate.java Sun
Jan 25 01:35:18 2009
@@ -20,6 +20,7 @@
  */
 
 import java.io.IOException;
+import java.io.StringReader;
 import java.io.Writer;
 
 import org.apache.velocity.context.EvaluateContext;
@@ -38,7 +39,7 @@
 import org.apache.velocity.util.introspection.Info;
 
 /**
- * Evaluates the macro argument as a Velocity string, using the existing
+ * Evaluates the directive argument as a VTL string, using the existing
  * context.
  *
  * @author <a href="mailto:wglass@apache.org">Will Glass-Husain</a>
@@ -158,7 +159,7 @@
 
         try
         {
-            nodeTree = rsvc.parse(sourceText, templateName);
+            nodeTree = rsvc.parse(new StringReader(sourceText), templateName, false);
         }
         catch (ParseException pex)
         {
@@ -179,8 +180,7 @@
 
         if (nodeTree != null)
         {
-            InternalContextAdapterImpl ica =
-                new InternalContextAdapterImpl( new EvaluateContext(context, rsvc) );
+            InternalContextAdapter ica = new EvaluateContext(context, rsvc);
 
             ica.pushCurrentTemplateName( templateName );
 

Modified: velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity682TestCase.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity682TestCase.java?rev=737465&r1=737464&r2=737465&view=diff
==============================================================================
--- velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity682TestCase.java
(original)
+++ velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity682TestCase.java
Sun Jan 25 01:35:18 2009
@@ -30,13 +30,13 @@
     public Velocity682TestCase(String name)
     {
         super(name);
-        DEBUG=true;
+        //DEBUG = true;
     }
   
     public void test682()
     {
-      engine.setProperty(RuntimeConstants.VM_PERM_INLINE_LOCAL, true);      
-      //assertEvalEquals("foo1foo2", "#macro(eval $e)#evaluate($e)#end#eval('foo1')#eval('foo2')");
+        engine.setProperty(RuntimeConstants.VM_PERM_INLINE_LOCAL, Boolean.TRUE);      
+        assertEvalEquals("foo1foo2", "#macro(eval $e)#evaluate($e)#end#eval('foo1')#eval('foo2')");
     }
 
     public void test682b()
@@ -51,11 +51,13 @@
 
     public void test682c()
     {
+        //NOTE: #eval call is apparently swallowing preceding newlines. :(
+        //      appears to be a parser issue unrelated to VELOCITY-682
         String template = "#macro( eval $e )#evaluate($e)#end" +
                           "\n#eval('foo')" +
-                          "\n#eval('bar')";
-        String expected = "\nfoo"+
+                          "\n\n#eval('bar')";
+        String expected = "foo"+
                           "\nbar";
-        //assertEvalEquals(expected, template);
+        assertEvalEquals(expected, template);
     }
 }



Mime
View raw message