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 (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. VincentMassol1 +XWiki.surli - Content
-
... ... @@ -40,7 +40,8 @@ 40 40 * **Macro description**: A short description of the macro to be displayed on the WYSIWYG editor 41 41 * **Default category**: Default category under which this macro should be listed 42 42 * **Supports inline mode**: Whether the macro can be used in an inline context or not 43 -* **Macro content type**: Whether this macro should support a body or not 43 +* **Macro Content availability**: {{warning}}before 11.5RC1 this was called **Macro Content Type**{{/warning}} whether this macro should support a body or not 44 +* **Macro content type**: {{warning}}this field has been renamed **Macro Content Availability** since 11.5RC1{{/warning}} the type of accepted content: two values are proposed, {{code}}WIKI{{/code}} if this content should be editable like a wiki content, or {{code}}UNKNOWN{{/code}} if it should be displayed like a plain text. It's also possible to specify a custom java type such as {{code}}java.util.List<java.lang.String>{{/code}}. Leaving the field blank is equivalent to {{code}}UNKWOWN{{/code}} value. 44 44 * **Content description**: A short description about the macro's content to be displayed on the WYSIWYG editor 45 45 * **Macro code**: The actual wiki code that will be evaluated when the macro is executed, can be any xwiki content (should be in the same syntax as the document) 46 46 * **Asynchronous rendering**: {{info}}Since 10.10{{/info}} Enabled or disable asynchronous rendering of the panel. Disabled by default. ... ... @@ -64,6 +64,7 @@ 64 64 == Content == 65 65 66 66 Starting with {{code}}XWiki 11.4RC1{{/code}} there are two ways to insert the content of the wiki macro. 68 + 67 67 * The easiest way is to use a dedicated macro in the body of the wikimacro:((( 68 68 {{code language="none"}} 69 69 {{wikimacrocontent/}} ... ... @@ -71,7 +71,7 @@ 71 71 72 72 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]]. 73 73 ))) 74 -* The older way to insert the content is b yexecuting the followingvelocitycodein the macro body:(((76 +* The older way to insert the content is to use the ##xcontext## binding. For example, when using Velocity, you can write the following script in the macro body:((( 75 75 {{code language="none"}} 76 76 {{velocity}}$xcontext.macro.content{{/velocity}} 77 77 {{/code}} ... ... @@ -99,6 +99,10 @@ 99 99 100 100 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 **$xcontext.macro.params.greetUser**. We plan to introduce some form of direct parameter binding in near future. 101 101 104 +Since {{info}}11.5RC1{{/info}}, it is also possible to display the content of a macro parameter by using a dedicated macro: 105 +{{code language="none"}}Hello {{wikimacroparameter name="greeUsers" /}} 106 +{{code}} 107 + 102 102 Finally, we can test our new version of **hello macro** with the following invocation: 103 103 104 104 {{code language="none"}} ... ... @@ -112,12 +112,10 @@ 112 112 #set ($greet = true) 113 113 {{hello greetUser="$greet"/}} 114 114 {{/velocity}} 115 -{{/code}} 121 +{{/code}}{{/code}} 116 116 117 117 == Translations == 118 118 119 - 120 - 121 121 When your macro is ready, you might want to provide the description of the macro and its parameters in different languages. For that, you need to create a set of translation keys and values (as described [[here>>platform:DevGuide.InternationalizingApplications]]) and then just use the following convention for the keys you add in this storage (no modification is needed on the macro itself, the association of the translations to the macro is done based on a convention of the form of the translation keys): 122 122 123 123 {{code}}