Dan1
July 29, 2008, 11:51am
#1
Hi,
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:
#field (“rx:fieldname”)
we get
<meta name=“name” content=",value1,value2,value3" />
So we obviously we just want to remove the initial ,
Cheers.
dbenua
July 30, 2008, 12:10pm
#2
Look at $tools.render.eval()
Dan1
July 31, 2008, 5:10am
#3
Hi,
Thanks for the response.
I have tried using the syntax given here: http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/RenderTool.html
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' )
$render.recurse($bar)
just prints out: “$render.recurse($bar)”
I have also tried the following as a test:
#set($regionsMacro = "#children('places' 'icrcSnRegionMetaTag' '' ',' '' '')")
<p>regions: $render.eval("$regionsMacro")</p>
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?
Cheers.
dbenua
July 31, 2008, 6:31am
#4
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.
Dave
Dan1
July 31, 2008, 11:23am
#5
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?
dbenua
August 1, 2008, 5:12pm
#6
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.
Dave