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
-
... ... @@ -6,20 +6,6 @@ 6 6 7 7 This page is a tutorial but you can also access the [[reference documentation for the Wiki Macro feature>>doc:extensions:Extension.WikiMacroStore.WebHome]]. 8 8 9 -= Macro Visibility and Rights = 10 - 11 -There are 3 levels of visibility for a macro: 12 - 13 -* ##Global## 14 -** on main wiki (or {{info}}before XWiki 10.4RC1{{/info}}) the macro will be available in all the pages of all the (sub)wikis. Requires the macro author to have **Programming Rights** 15 -** on subwiki {{info}}in 10.4RC1+{{/info}} synonym of ##Current Wiki## visibility 16 -* ##Current Wiki##, which means that the macro will be available in all the pages of the wiki the macro is in. Requires the macro author to have **Admin Rights** 17 -* ##Current User##, which means that the macro will only be available to the user who is its author. No special rights required. 18 - 19 -== Using protected API in wiki macros == 20 - 21 -Also, if the macro needs to use [[protected API>>platform:DevGuide.Scripting||anchor="HXWikiCoreAccess"]], the author of the macro will need to have programming rights. Note that the macro will always be executed with the rights of its author, and not with the rights of the author of the calling document (the document using the macro). Specifically, if the macro uses protected API, only the macro author needs to have programming rights, not all the authors of the documents that call this macro. 22 - 23 23 = Hello Macro = 24 24 25 25 We are going to start with a very simple xwiki/2.0 wiki macro which prints a greeting message to the document content. It isn't a very useful macro but the idea is to get you familiarised with the wiki macro creation process. ... ... @@ -32,7 +32,6 @@ 32 32 There can be only one object of type ##XWiki.WikiMacroClass## per wiki page (if you add more only the first will be used). 33 33 {{/warning}} 34 34 35 - 36 36 This class contains the following fields: 37 37 38 38 * **Macro id**: Id of the macro to be used by users when invoking your macro from wiki code ... ... @@ -64,7 +64,8 @@ 64 64 65 65 == Content == 66 66 67 -Starting with {{code}}XWiki 11.4RC1{{/code}} there are two ways to insert the content of the wiki macro. 52 +{{version since='11.4RC1'}} 53 +There are two ways to insert the content of the wiki macro. 68 68 69 69 * The easiest way is to use a dedicated macro in the body of the wikimacro:((( 70 70 {{code language='none'}} ... ... @@ -78,8 +78,9 @@ 78 78 {{velocity}}$wikimacro.content{{/velocity}} 79 79 {{/code}} 80 80 ))) 67 +{{/version}} 81 81 82 -For more details, see the [[Scripting Tips section below>> platform:DevGuide.WikiMacroTutorial||anchor="HScriptingTips"]].69 +For more details, see the [[Scripting Tips section below>>||anchor="HScriptingTips"]]. 83 83 84 84 == Parameters == 85 85 ... ... @@ -151,6 +151,24 @@ 151 151 rendering.macro.hello.parameter.greetUser.description=Personnaliser le message pour l'utilisateur courant en train de visualiser la page. Les valeurs possibles sont "true" (oui) et "false" (non). 152 152 {{/code}} 153 153 141 += Macro Visibility and Rights = 142 + 143 +There are 3 levels of visibility for a macro: 144 + 145 +* ##Global## 146 +** on main wiki (or {{info}}before XWiki 10.4RC1{{/info}}) the macro will be available in all the pages of all the (sub)wikis. Requires the macro author to have **Programming Rights** 147 +** on subwiki {{info}}in 10.4RC1+{{/info}} synonym of ##Current Wiki## visibility 148 +* ##Current Wiki##, which means that the macro will be available in all the pages of the wiki the macro is in. Requires the macro author to have **Admin Rights** 149 +* ##Current User##, which means that the macro will only be available to the user who is its author. No special rights required. 150 + 151 +== Using protected API in wiki macros == 152 + 153 +Also, if the macro needs to use [[protected API>>platform:DevGuide.Scripting||anchor="HXWikiCoreAccess"]], the author of the macro will need to have programming rights. Note that the macro will always be executed with the rights of its author, and not with the rights of the author of the calling document (the document using the macro). Specifically, if the macro uses protected API, only the macro author needs to have programming rights, not all the authors of the documents that call this macro. 154 + 155 += Bindings = 156 + 157 +See all availalbe bindings in [[the reference documentation page>>doc:extensions:Extension.WikiMacroStore.WebHome||anchor="HBindings"]]. 158 + 154 154 = WYSIWYG Access = 155 155 156 156 A wiki macros is treated just like any other rendering macro in the system. As such, the moment you save your wiki macro it will be available to the users through the WYSIWYG editor's **Insert Macro** dialog box: ... ... @@ -192,7 +192,6 @@ 192 192 193 193 Following are a few useful hints if you plan to do advanced scripting inside your wiki macros: 194 194 195 -* See all bindings in [[the reference documentation page>>doc:extensions:Extension.WikiMacroStore.WebHome||anchor="HBindings"]]. 196 196 * 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:((( 197 197 {{code language='groovy'}} 198 198 {{groovy}}