You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Charles Harvey III <ch...@alloy.com> on 2008/12/23 17:11:26 UTC
#set() in #macro()
Hello.
I could have sworn that I used to be able to set a variable in a macro and
then render that variable after the macro was called. But I seem to be
wrong
about this. Here is an example:
-------------------------------------
/macros.vm
#macro( setVariable )
#set( $variable = "Velocity" )
#end
-------------------------------------
-------------------------------------
/mypage.vm
#setVariable()
$variable
-------------------------------------
Doesn't render. It just prints "$variable" to the page. Is this
supposed to
work? Or am I doing something that shouldn't be done?
Thanks.
Charlie
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: #set() in #macro()
Posted by Byron Foster <by...@base2.cc>.
look at the 'velocimacro.context.localscope' property in the
configuration. When it's set to 'true' you'll get the behavior you
describe. It's false by default.
On Dec 23, 2008, at 9:11 , Charles Harvey III wrote:
> Hello.
> I could have sworn that I used to be able to set a variable in a
> macro and
> then render that variable after the macro was called. But I seem to
> be wrong
> about this. Here is an example:
>
> -------------------------------------
> /macros.vm
> #macro( setVariable )
> #set( $variable = "Velocity" )
> #end
> -------------------------------------
>
> -------------------------------------
> /mypage.vm
> #setVariable()
> $variable
> -------------------------------------
>
>
> Doesn't render. It just prints "$variable" to the page. Is this
> supposed to
> work? Or am I doing something that shouldn't be done?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org