velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Brandner <robert.brand...@chello.at>
Subject Unset variables?
Date Sun, 22 Aug 2004 16:10:56 GMT
Hi!

Isn't there a possibility to unset a variable (or set it to null)?

Given the following macro 'demo' and 2 objects o1 with action==null and 
o2 with action != null.

#macro(demo $object)
   #set($action = $object.action)
   #if($action)
     ## do something
   #end
#end

Now, when I call #demo($o1) the variable $action is not set and the 
macro does nothing - as expected.

Now, I call #demo($o2) $action gets set (as o2 has an action) and the 
macro 'does something' - as expected.

But when I call #demo($o1) again, $action stays set (even though 
o1.action == null) and the macro does something?! Strange!

And a second question: Is there a possibility to have 'local' variables 
within a macro? I suppose not -- I guess I think of a macro as a 
function but that's not the case, right?

Best regards

Robert



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message