Last modified by Simon Urli on 2023/10/10

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

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.MichaelHamann
1 +XWiki.ThomasMortagne
Content
... ... @@ -51,13 +51,20 @@
51 51  == Content ==
52 52  
53 53  {{version since="11.4RC1"}}
54 -The easiest way to insert the content of the wiki macro is to use a dedicated macro in the body of the wikimacro:
54 +There are two ways to insert the content of the wiki macro.
55 55  
56 +* The easiest way is to use a dedicated macro in the body of the wikimacro:(((
56 56  {{code language='none'}}
57 57  {{wikimacrocontent/}}
58 58  {{/code}}
59 59  
60 60  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 +)))
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 +)))
61 61  {{/version}}
62 62  
63 63  For more details, see the [[Scripting Tips section below>>||anchor="HScriptingTips"]].
... ... @@ -82,7 +82,7 @@
82 82  {{code language="none"}}
83 83  {{velocity}}
84 84  #if ($wikimacro.parameters.greetUser && "XWiki.XWikiGuest" != "$xcontext.user")
85 - Hello $services.rendering.escape($xwiki.user.email, 'xwiki/2.1')!
92 + Hello $xwiki.user.email!
86 86  #else
87 87   Hello world!
88 88  #end
... ... @@ -92,7 +92,7 @@
92 92  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.
93 93  
94 94  Since {{info}}11.5RC1{{/info}}, it is also possible to display the content of a macro parameter by using a dedicated macro:
95 -{{code language="none"}}Hello {{wikimacroparameter name="greetUsers" /}}{{/code}}
102 +{{code language="none"}}Hello {{wikimacroparameter name="greeUsers" /}}{{/code}}
96 96  
97 97  Finally, we can test our new version of **hello macro** with the following invocation:
98 98  
... ... @@ -211,7 +211,7 @@
211 211  This text will not appear in the result.
212 212  {{/code}}
213 213  )))
214 -* 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:(((
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:(((
215 215  {{code language="velocity"}}
216 216  {{velocity output="no"}}
217 217  ## get the macro content in a velocity string
... ... @@ -238,11 +238,11 @@
238 238  {{velocity}}
239 239  #set($greetUser=$xcontext.macro.params.greetUser)
240 240  #if ("true" == $greetUser && "XWiki.XWikiGuest" != "$xcontext.user" )
241 - Hello $services.rendering.escape($xwiki.user.email, 'xwiki/2.1')!
248 + Hello $xwiki.user.email!
242 242  #else
243 243   Hello world!
244 244  #end
245 -{{/velocity}}
252 +<img src="$image" width="$width" />
246 246  {{/code}}
247 247  
248 248  If we invoke it twice in a row:

Get Connected