You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Dan Milstein <da...@shore.net> on 2002/06/07 17:49:07 UTC

Macro Question

If I define a macro in the global velocimacro library, can it resolve
references to objects in the context passed in to a given page?

For example:

 1) Java code:  ctx.put("hello", "world");  Merges that ctx into
'a-template.vtl'

 2) in 'a-template.vtl':
#hey()

 3) global library:

#macro ( hey ) 
<b>$hello</b>
#end


Will this output:

<b>world</b>

or

<b>$hello</b>

-Dan Milstein

-- 

Dan Milstein // danmil@shore.net

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Macro Question

Posted by Simon Christian <si...@cpd.co.uk>.
Put simply, yes it'll output (<b>world</b>) ;)

It's worth knowing the effect of the 'velocimacro.context.localscope' 
configuration value though: by default this is false and has no effect 
but if set to true, use of the context from within macros will not be 
able to change it globally.

- simon

Dan Milstein wrote:
> If I define a macro in the global velocimacro library, can it resolve
> references to objects in the context passed in to a given page?
> 
> For example:
> 
>  1) Java code:  ctx.put("hello", "world");  Merges that ctx into
> 'a-template.vtl'
> 
>  2) in 'a-template.vtl':
> #hey()
> 
>  3) global library:
> 
> #macro ( hey ) 
> <b>$hello</b>
> #end
> 
> 
> Will this output:
> 
> <b>world</b>
> 
> or
> 
> <b>$hello</b>
> 
> -Dan Milstein


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>