velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: How to load a macro from file (again!!!)
Date Tue, 06 Jan 2009 16:21:03 GMT
On Mon, Jan 5, 2009 at 4:15 PM, Jude Robinson
<dotcode+velocity@gmail.com> wrote:
>> Oh, and if you were using Velocity 1.6.1, then you could use #parse to
>> load your macros.
>
> <finally stops lurking/> Hello.
>
> Using #parse to load macros - that sounds interesting - can you give
> an example, and explain when/why that may be useful?


i don't think it's often useful; most of the time there's another,
better way.  but there are those who have needed it.  not having been
one myself, i don't have a great example.  but here's a made up one:

---foo.vm----
#macro(  link $page )http://foo.com/$page#end
#macro(  blah $x )Do y with $x here#end
...

---bar.vm----
#macro( link $page )http://bar.com/$page#end
#macro( blah $x )Do z with $x here#end
...

---template.vm----
#if( $user.foo )
#parse( 'foo.vm' )
#else
#parse( 'bar.vm' )
#end
Hello $user.name,
<a href="#link( 'home.html' )">#blah( 'your account' )</a>.
sincerely,
george of the jungle

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


Mime
View raw message