macro variables

View: New views
4 Messages — Rating Filter:   Alert me  

macro variables

by Charles Harvey III :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello.
I am setting a variable in my macros.vm file and trying to print it in
my template and it does
not display.  I was wondering if I was doing something wrong or if there
is a bug.


macros.vm:
---------------------------------------------------------
#macro( testing )
    #set( $myVar = "testing" )
    macro myVar: $myVar<br />
#end
---------------------------------------------------------


template.vm
---------------------------------------------------------
#testing()
template myVar: $myVar<br /><br />
---------------------------------------------------------


velocity.properties
---------------------------------------------------------
velocimacro.library = /macros.vm
velocimacro.library.autoreload = true
velocimacro.permissions.allow.inline = true
velocimacro.permissions.allow.inline.to.replace.global = true
velocimacro.permissions.allow.inline.local.scope = true
velocimacro.context.localscope = true
---------------------------------------------------------


output:
---------------------------------------------------------
macro myVar: testing
template myVar: $myVar
---------------------------------------------------------


Am I doing something wrong?  Shouldn't this work?  Thanks for the help.


Charlie



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: macro variables

by Charles Harvey III :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh, right.  Velocity-1.6.2 is my version.


Charlie



Charles Harvey III wrote:

> Hello.
> I am setting a variable in my macros.vm file and trying to print it in
> my template and it does
> not display.  I was wondering if I was doing something wrong or if
> there is a bug.
>
>
> macros.vm:
> ---------------------------------------------------------
> #macro( testing )
>    #set( $myVar = "testing" )
>    macro myVar: $myVar<br />
> #end
> ---------------------------------------------------------
>
>
> template.vm
> ---------------------------------------------------------
> #testing()
> template myVar: $myVar<br /><br />
> ---------------------------------------------------------
>
>
> velocity.properties
> ---------------------------------------------------------
> velocimacro.library = /macros.vm
> velocimacro.library.autoreload = true
> velocimacro.permissions.allow.inline = true
> velocimacro.permissions.allow.inline.to.replace.global = true
> velocimacro.permissions.allow.inline.local.scope = true
> velocimacro.context.localscope = true
> ---------------------------------------------------------
>
>
> output:
> ---------------------------------------------------------
> macro myVar: testing
> template myVar: $myVar
> ---------------------------------------------------------
>
>
> Am I doing something wrong?  Shouldn't this work?  Thanks for the help.
>
>
> Charlie
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: macro variables

by Alexander-129 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try with velocimacro.context.localscope = false 

2009/7/30 Charles Harvey III <charlieh@...>
Oh, right.  Velocity-1.6.2 is my version.


Charlie




Charles Harvey III wrote:
Hello.
I am setting a variable in my macros.vm file and trying to print it in my template and it does
not display.  I was wondering if I was doing something wrong or if there is a bug.


macros.vm:
---------------------------------------------------------
#macro( testing )
  #set( $myVar = "testing" )
  macro myVar: $myVar<br />
#end
---------------------------------------------------------


template.vm
---------------------------------------------------------
#testing()
template myVar: $myVar<br /><br />
---------------------------------------------------------


velocity.properties
---------------------------------------------------------
velocimacro.library = /macros.vm
velocimacro.library.autoreload = true
velocimacro.permissions.allow.inline = true
velocimacro.permissions.allow.inline.to.replace.global = true
velocimacro.permissions.allow.inline.local.scope = true
velocimacro.context.localscope = true
---------------------------------------------------------


output:
---------------------------------------------------------
macro myVar: testing
template myVar: $myVar
---------------------------------------------------------


Am I doing something wrong?  Shouldn't this work?  Thanks for the help.


Charlie



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...



Re: macro variables

by Charles Harvey III :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That was it.  I've had that set in a bunch of webapps for like 2 years.  
Thanks for pointing
that out - big help.


Charlie



Alexander wrote:

> Try with velocimacro.context.localscope = false
>
> 2009/7/30 Charles Harvey III <charlieh@...
> <mailto:charlieh@...>>
>
>     Oh, right.  Velocity-1.6.2 is my version.
>
>
>     Charlie
>
>
>
>
>     Charles Harvey III wrote:
>
>         Hello.
>         I am setting a variable in my macros.vm file and trying to
>         print it in my template and it does
>         not display.  I was wondering if I was doing something wrong
>         or if there is a bug.
>
>
>         macros.vm:
>         ---------------------------------------------------------
>         #macro( testing )
>           #set( $myVar = "testing" )
>           macro myVar: $myVar<br />
>         #end
>         ---------------------------------------------------------
>
>
>         template.vm
>         ---------------------------------------------------------
>         #testing()
>         template myVar: $myVar<br /><br />
>         ---------------------------------------------------------
>
>
>         velocity.properties
>         ---------------------------------------------------------
>         velocimacro.library = /macros.vm
>         velocimacro.library.autoreload = true
>         velocimacro.permissions.allow.inline = true
>         velocimacro.permissions.allow.inline.to.replace.global = true
>         velocimacro.permissions.allow.inline.local.scope = true
>         velocimacro.context.localscope = true
>         ---------------------------------------------------------
>
>
>         output:
>         ---------------------------------------------------------
>         macro myVar: testing
>         template myVar: $myVar
>         ---------------------------------------------------------
>
>
>         Am I doing something wrong?  Shouldn't this work?  Thanks for
>         the help.
>
>
>         Charlie
>
>
>
>         ---------------------------------------------------------------------
>         To unsubscribe, e-mail: user-unsubscribe@...
>         <mailto:user-unsubscribe@...>
>         For additional commands, e-mail: user-help@...
>         <mailto:user-help@...>
>
>
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-unsubscribe@...
>     <mailto:user-unsubscribe@...>
>     For additional commands, e-mail: user-help@...
>     <mailto:user-help@...>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...