Changes for page Writing XWiki Rendering Macros in wiki pages
Last modified by Simon Urli on 2023/10/10
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -182,11 +182,7 @@ 182 182 183 183 Following are a few useful hints if you plan to do advanced scripting inside your wiki macros: 184 184 185 -* Old and new bindings: please note that the ##$wikimacro## binding is only available since {{info}}XWiki 10.11.9, 11.3.2 and 11.6RC1{{/info}}, before that the ##$xcontext.macro## binding should be used. You can get more information on [[the reference documentation page>>doc:extensions:Extension.WikiMacroStore.WebHome||anchor="HBindings"]] 186 -* Access parameters: Use the wikimacro object (Ex. ##$wikimacro.params.param1##) 187 -* Access macro body (if your macro defines one): Use the wikimacro object (Ex. ##$wikimacro.content##) 188 -* Access the wiki macro document: ##$wikimacro.doc## 189 -* Access [[MacroTransformationContext>>https://github.com/xwiki/xwiki-rendering/blob/master/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/transformation/MacroTransformationContext.java]]: Use the wikimacro object (Ex. ##$wikimacro.context##) 185 +* See all bindings in [[the reference documentation page>>doc:extensions:Extension.WikiMacroStore.WebHome||anchor="HBindings"]]. 190 190 * Since 2.4M1, it's possible to directly return the desired list of rendering blocks without having to render them first to let them be parsed back by the macro transformation. The benefits are that it could be a lots quicker and most of all it means supporting syntax which does not provide any renderer. It also makes it possible to generate some XDOM which is impossible to write in any some syntax. For example the following wiki macro is generating a LinkBlock targeting a relative URL:((( 191 191 {{code language="groovy"}} 192 192 {{groovy}} ... ... @@ -208,7 +208,7 @@ 208 208 {{/code}} 209 209 ))) 210 210 * 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:((( 211 -{{code langu ege="velocity"}}207 +{{code language="velocity"}} 212 212 {{velocity output="no"}} 213 213 ## get the macro content in a velocity string 214 214 #set($wikiresult = $wikimacro.content) ... ... @@ -219,7 +219,6 @@ 219 219 {{/velocity}} 220 220 {{/code}} 221 221 ))) 222 -* Since 9.1RC1 you can access the macro descriptor using ##$xcontext.macro.descriptor## binding. It returns a ##org.xwiki.rendering.macro.descriptor.MacroDescriptor## Java object. 223 223 224 224 = Troubleshooting = 225 225