Re: What does "Velocimacro with a Body" mean?

"O. Olson" <[email protected]> Wed, 7 Aug 2013 23:10:26 +0100 (BST)
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <[email protected]>

Thank you very much Sergiu  and Alex. 
 
            I was just
about to post to Sergiu that I could not get his suggestion to work, when I saw the post from Alex. 
 
Thank you Alex. You are totally
correct here – your suggestion worked perfectly and solved my problem.
 
Thanks again to both of you,
O. O.
 
 
 


----- Messaggio originale -----
Da: Alex Fedotov <[email protected]>
A: Velocity Users List <[email protected]>; O. Olson <[email protected]>
Cc: Nathan Bubna <[email protected]>
Inviato: Mercoledì 7 Agosto 2013 16:25
Oggetto: Re: What does "Velocimacro with a Body" mean?

It does not work because bodyContent is an instance of the ASTNode class
and not a string, so it does not have the trim method.

Use something like this:

#macro(my_trim)#set($str="$bodyContent")$str.trim()#end

Test:

before#@my_trim()    -blah-     #{end}after

Renders:
before-blah-after