<
From version < 120.1 >
edited by Thomas Mortagne
on 2022/01/04
To version < 121.1 >
edited by Michael Hamann
on 2022/06/28
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ThomasMortagne
1 +XWiki.MichaelHamann
Content
... ... @@ -60,11 +60,6 @@
60 60  
61 61  Note that by default this makes the content of the macro directly editable in [[the WYSIWYG editor>>https://extensions.xwiki.org/xwiki/bin/view/Extension/CKEditor%20Integration/#HWikiMacros]].
62 62  )))
63 -* Another way to manipulate the content is to use the wikimacro binding. For example, when using Velocity, you can write the following script in the macro body:(((
64 -{{code language='none'}}
65 -{{velocity}}$wikimacro.content{{/velocity}}
66 -{{/code}}
67 -)))
68 68  {{/version}}
69 69  
70 70  For more details, see the [[Scripting Tips section below>>||anchor="HScriptingTips"]].
... ... @@ -89,7 +89,7 @@
89 89  {{code language="none"}}
90 90  {{velocity}}
91 91  #if ($wikimacro.parameters.greetUser && "XWiki.XWikiGuest" != "$xcontext.user")
92 - Hello $xwiki.user.email!
87 + Hello $services.rendering.escape($xwiki.user.email, 'xwiki/2.1')!
93 93  #else
94 94   Hello world!
95 95  #end
... ... @@ -99,7 +99,7 @@
99 99  As you might have realized already, direct binding of parameters is not supported at the moment. That is, you cannot access //greetUser// parameter with **$greetUser**. Instead you must use **$wikimacro.parameters.greetUser**. We plan to introduce some form of direct parameter binding in near future.
100 100  
101 101  Since {{info}}11.5RC1{{/info}}, it is also possible to display the content of a macro parameter by using a dedicated macro:
102 -{{code language="none"}}Hello {{wikimacroparameter name="greeUsers" /}}{{/code}}
97 +{{code language="none"}}Hello {{wikimacroparameter name="greetUsers" /}}{{/code}}
103 103  
104 104  Finally, we can test our new version of **hello macro** with the following invocation:
105 105  
... ... @@ -218,7 +218,7 @@
218 218  This text will not appear in the result.
219 219  {{/code}}
220 220  )))
221 -* If you are using ##$wikimacro.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:(((
216 +* If you need to directly access the parsed XDOM of the content you may do the parsing yourself using the rendering service. Here is a small sample:(((
222 222  {{code language="velocity"}}
223 223  {{velocity output="no"}}
224 224  ## get the macro content in a velocity string
... ... @@ -245,11 +245,10 @@
245 245  {{velocity}}
246 246  #set($greetUser=$xcontext.macro.params.greetUser)
247 247  #if ("true" == $greetUser && "XWiki.XWikiGuest" != "$xcontext.user" )
248 - Hello $xwiki.user.email!
243 + Hello $services.rendering.escape($xwiki.user.email, 'xwiki/2.1')!
249 249  #else
250 250   Hello world!
251 251  #end
252 -<img src="$image" width="$width" />
253 253  {{/code}}
254 254  
255 255  If we invoke it twice in a row:

Get Connected