velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr <g...@4quarters.com>
Subject Re: Local variable within templates
Date Fri, 09 Jan 2004 12:43:17 GMT

On Jan 9, 2004, at 7:29 AM, Ryan Lea wrote:

> Hi,
>
> Is it possible to declare apparent local variables within VTL.  The  
> best way
> to explain what Im actually talking about is by example ...
>
> **template1.vm**
>
> #set ( $a = 5 )
>
> **template2.vm**
> #set ( $a = 0 )
> #parse ("template1.vm")
> $a
>
> Where my desired output would be:
>
> 0
>
> Rather than:
>
> 5
>
> I realise that parsing gives you an advantage to load a number of  
> constants
> or commonly used variables per page, but it would be nice to be able to
> reuse variable names without fear of overwriting them.  I have found  
> this
> particularly frustrating when using macros as well (more laziness in  
> that
> regard though).
>
> Any ideas on a way around this or is it just a fact of life ill have  
> to deal
> with??

There is a unsupported directive called 'local'.  Go to

contrib/temporary/localdirective

geir

>
> Cheers
>
>
>
> Ryan Lea
> Web Developer
>
>
> _______________________________________________________________________ 
> _
> This email has been scanned for all viruses by the MessageLabs service.
> _______________________________________________________________________ 
> _
>
-- 
Geir Magnusson Jr                                   203-247-1713(m)
geir@4quarters.com


---------------------------------------------------------------------
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