velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Revusky <>
Subject Re: What's in the future for Velocity?
Date Thu, 10 Oct 2002 21:54:33 GMT
On Thursday 10 October 2002 06:53 pm, Jason Weinstein wrote:
> I'd like to see the ability to denote the scope of variables.
> I'd especially like to have a local scope inside of a macro.
> #setlocal () perhaps

Well, FreeMarker, as of version 2.1, has this feature. It's

<local foo="bar">

from within a macro.

> I think there are other scoping issues that I would consider although I am
> not sure how velocity is handling scope for instance when a file is
> #include(d) or #parse(d) since I have not used these features.
> I'd also like to have an
> #endif
> #endmacro
> #endforeach
> for readability.
> (Name not important, just like to know what construct is ending)

You might like FreeMarker syntax in that case, since a macro is ended with 
</macro> and an <if> block ends with </if> and <foreach> with </foreach>
so on.

> See example below for scoping issue.
> Calling the #macro sets $macroTemp, $macroI, $macroK globally. This makes
> it difficult to call another #macro from within a #macro do to possible
> naming conflicts.

Yeah, in terms of macros being reusable in a robust manner, one really needs 
to be able to have local variables.

Well, anyway, it's up to you. If you like Velocity, use that. OTOH, if you 
want to read more about what Freemarker has to offer, you can look here for a 
comparison of the two template engines.

And here is information about how to transition from Vel->FM, if that ends up 
being what you want to do. :-)


Jonathan Revusky
lead developer FreeMarker
Build robust web applications with the Niggle Web Application Framework

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

View raw message