velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arvind Srinivasan <>
Subject re: macros embedded in content
Date Fri, 28 Apr 2006 00:14:42 GMT

Sorry, i had failed to mention that #bolder ('welcome john doe') in the code
below works as expected though !

just that when, the list of colors get printed, it gets printed as plain text....

do you still think, it is clubbed with the existing macro issues ?



Will Glass-Husain
Thu, 27 Apr 2006 16:53:25 -0700
You cannot parse a file containing macros and have them work reliably in the
main page. See

You can however collect all your macros together and put them in
VM_global_library.vm. All such macros will be loaded at initialization time.



P.S. As an aside, send followup or further questions to the users list please,

Arvind Srinivasan wrote:

    Sorry, if this has question of mine has been posted already - i am really not
    sure about the terminology used to search....

    We are researching on usage of velocity at our place....we have setup
    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, in,
    user-generated content using system defined velocity macros.


    ##define a macro to 'bold' the output text in bold.vm
    #macro (bolder $text)

    final template.....

    Template (foo.vm)

    #parse ('bold.vm')


    #bolder ('welcome john doe')

    #foreach ($color in $colorlist)
      $color (<!--pardon any syntax error - and assume the pseudo code works)



    The user maintains $colorlist (externally in a database as)  red, blue, #bolder
    ('green'), black, #bolder('yellow')  - and the expectation is that the list when
    printed, would contain the text green and yellow in bold..(as per the #bolder

    macro behavior)

    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 ?

    p.s :  I have posted the same in google java groups and hope does not come

    across as cross posting.

    To unsubscribe, e-mail: [EMAIL PROTECTED]
    For additional commands, e-mail: [EMAIL PROTECTED]

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

View raw message