Last modified by Clément Desableau on 2023/06/01

<
From version < 80.3 >
edited by Vincent Massol
on 2012/02/12
To version < 81.1 >
edited by Denis Gervalle
on 2013/02/19
>
Change comment: Add a sample of parsing macro content in velocity to avoid nested scripting error

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.VincentMassol
1 +XWiki.dgervalle
Content
... ... @@ -144,7 +144,15 @@
144 144  This text will not appear in the result.
145 145  {code}
146 146  
147 +* If you are using \$xcontext.macro.content in your velocity macro, that content will not be able to support scripting, since nested scripting is not supported. To workaround that limitation, thanks to the above, you may do the parsing yourself using the rendering service. Here is a small sample:
147 147  
149 +{code}
150 +{{velocity output="no"}}
151 +#set($wikiresult = $xcontext.macro.content) ## get the macro content in a velocity string
152 +#set($wikiresult = "(% class='newstyle' %)((($wikiresult)))") ## Add a wrapping div as a sample of what the macro could do
153 +#set($xcontext.macro.result = $services.rendering.parse($wikiresult, $xwiki.getCurrentContentSyntaxId()).getChildren()) ## parse the string and return the resulting blocks
154 +{{/velocity}}
155 +{code}
148 148  1.1 Troubleshooting
149 149  
150 150  1.1.1 A Pitfall of Optional Parameters

Get Connected