velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wgl...@apache.org
Subject svn commit: r676393 - in /velocity/engine/trunk: src/java/org/apache/velocity/context/VMContext.java test/set/compare/set2.cmp test/set/set2.vm
Date Sun, 13 Jul 2008 18:23:07 GMT
Author: wglass
Date: Sun Jul 13 11:23:07 2008
New Revision: 676393

URL: http://svn.apache.org/viewvc?rev=676393&view=rev
Log:
Fix a problem in which context.remove wasn't working within macros.  Fixes bug VELOCITY-594.

Modified:
    velocity/engine/trunk/src/java/org/apache/velocity/context/VMContext.java
    velocity/engine/trunk/test/set/compare/set2.cmp
    velocity/engine/trunk/test/set/set2.vm

Modified: velocity/engine/trunk/src/java/org/apache/velocity/context/VMContext.java
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/context/VMContext.java?rev=676393&r1=676392&r2=676393&view=diff
==============================================================================
--- velocity/engine/trunk/src/java/org/apache/velocity/context/VMContext.java (original)
+++ velocity/engine/trunk/src/java/org/apache/velocity/context/VMContext.java Sun Jul 13 11:23:07
2008
@@ -259,7 +259,37 @@
      */
     public Object remove(Object key)
     {
-        return vmproxyhash.remove( key );
+        /*
+         *  first see if this is a vmpa
+         */
+
+        VMProxyArg vmpa = (VMProxyArg) vmproxyhash.get( key );
+
+        if( vmpa != null)
+        {
+            return vmproxyhash.remove( key );
+        }
+        else
+        {
+            if( localcontextscope )
+            {
+                /*
+                 *  remove from local context
+                 */
+                return localcontext.remove(key);
+            }
+            
+            /**
+             * remove from local context, or if not there, remove from inner context
+             */
+            Object oldValue = localcontext.remove(key);
+            if (oldValue == null)
+            {
+                oldValue = innerContext.remove(key);
+            }
+            return oldValue;
+        }
+
     }
 
     /**

Modified: velocity/engine/trunk/test/set/compare/set2.cmp
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/set/compare/set2.cmp?rev=676393&r1=676392&r2=676393&view=diff
==============================================================================
--- velocity/engine/trunk/test/set/compare/set2.cmp (original)
+++ velocity/engine/trunk/test/set/compare/set2.cmp Sun Jul 13 11:23:07 2008
@@ -7,3 +7,7 @@
 bar
 foo
 $map.bar
+
+
+test 
+$test 

Modified: velocity/engine/trunk/test/set/set2.vm
URL: http://svn.apache.org/viewvc/velocity/engine/trunk/test/set/set2.vm?rev=676393&r1=676392&r2=676393&view=diff
==============================================================================
--- velocity/engine/trunk/test/set/set2.vm (original)
+++ velocity/engine/trunk/test/set/set2.vm Sun Jul 13 11:23:07 2008
@@ -15,3 +15,15 @@
 #set($map.bar = $boohoo) 
 $map.foo
 $map.bar
+
+##
+## check a macro
+##
+
+#macro (test) 
+#set ($test = "test") 
+$test 
+#set ($test = $null) 
+$test 
+#end 
+#test() 



Mime
View raw message