velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Brandner <>
Subject Unset variables?
Date Sun, 22 Aug 2004 16:10:56 GMT

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)
     ## do something

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


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message