Velocity: Manipulating the output of a macro


Is there a way to alter the output of a macro, or to store it in a variable to be altered?

We are using the #children macro to retrieve the values from a child table on some of our items to include in metadata on a page.

By using the following:
<meta name=“name” content="#children(“places” “template” “” “,” “” “”)" />

with “template” defined simply as:

we get
<meta name=“name” content=",value1,value2,value3" />

So we obviously we just want to remove the initial ,


Look at $tools.render.eval()


Thanks for the response.

I have tried using the syntax given here:

It doesn’t have an example of my exact situation but i have tried using the sample code as a test and can’t get that to work either.

  #macro( say_hi )hello world!#end
  #set( $foo = '#say_hi()' )
  #set( $bar = '$foo' )

just prints out: “$render.recurse($bar)”

I have also tried the following as a test:

 #set($regionsMacro = "#children('places' 'icrcSnRegionMetaTag' '' ',' '' '')")
 &lt;p&gt;regions: $render.eval("$regionsMacro")&lt;/p&gt;

but this just prints out: “regions: $render.eval(”$regionsMacro")"

Is there something I am missing here which I need to do to be able to access these methods from my template or do I just not have the correct syntax?


To access the tools in Rhythmyx, you have to use $tools.render not $render.

I’m not sure that recurse is the thing you want to do, unless your macro defines other macros. It seems to me that if you want the output of a macro, eval() does what you want.


I’ve tried that syntax but it has the same affect.

I’m planning to use the eval method in my call, I only used the recurse method to keep the example exactly as it was.

Is there some configuration I need to do to insure that $tools are accessible?

It appears that the Render Tool is broken in current versions of Rhythmyx, so this isn’t an option after all.

I don’t see any easy way to work around this at the moment.