Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Velocity and macros embedded in content

Thread view: 
Arvind - 26 Apr 2006 21:14 GMT
We are researching on usage of velocity at our place....we havesetup
velocity with templates being loaded from databases, setup for using
the macros etc.

If the 'rendered' content has VTL code in it, I am curious, as to
how/whether we can support 'another pass' of velocity, ..as in,
user-generated content using system defined velocity macros.

hypothetical example....

##define a macro to 'bold' the output text in bold.vm
#macro (bolder $text)
<b>$text</b>
#end

actual template.....
Template (foo.vm)

#parse ('bold.vm')

<html>

#bolder ('welcome john doe')

#foreach
 <!--print some list of items and items themselves contain #bolder
(sometext) -->
#end
</html>

When the velocity engine is done with its work, #bolder (sometext) does
not get evaluated and it gets printed out as-is

This requirement is like the usage of macros in confluence (atlassian)
etc - just curious whether there are users who have used velocity for
this purpose. If there are - any best practises/things to watch out for
?

Are there other ways of handling such requirements ?

Thanks for your time.

--
Arvind
Jean-Francois Briere - 26 Apr 2006 22:43 GMT
You cannot use #parse to do that.
You must define bold.vm in the velocimacro.library properties before
executing the Velocity engine.
You could also insert the velocimacro directly into the template
foo.vm.

Regards
Arvind - 26 Apr 2006 23:35 GMT
> You cannot use #parse to do that.
> You must define bold.vm in the velocimacro.library properties before
> executing the Velocity engine.
> You could also insert the velocimacro directly into the template
> foo.vm.

Thanks - I think i failed to add that - #bolder ('welcome john doe')
works perfectly ok in the example specified above.

What fails however is as follows...let us consider the example of a
vector of colors am printing out - and the colors can be
entered/maintained by the user....

i.e. the user maintains, red, blue, #bolder ('green'), black, #bolder
('yellow')  - expecting that the list when printed, would contain the
text green and yellow in bold..(as per the macro behavior)

When velocity engine runs thru the list....it prints them as specified
by the user....however, we would rather that, velocity engine, wait for
the output, which would now contain, some more velocity templates/macro
references and do one-more pass...

Hope i made myself clear ?

--
Arvind


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.