Thomas and Vincent, thank you both for the feedback. If parameters supported data type it
would open up a lot of nice options for wiki macros but I can manage without. It's
easy enough to fake the Boolean type and the macro I wanted to use arrays is just for
building the site pages and not for production use, so I can hard code my lists easy
enough. Thanks again!
Regards,
Jesse
On Apr 3, 2016, at 8:59 AM, Vincent Massol
<vincent(a)massol.net> wrote:
On 03 Apr 2016, at 02:02, Personal
<jesse(a)abrightfamily.com> wrote:
Is it possible to pass an array as a macro parameter? So far my attempts have failed.
no, it’s not really possible to pass typed parameters to macros in wiki syntax.
However, if the macro is written in Java and it expects a List<String>, and you
pass a comma-separated list, XWiki will convert the string to List automatically.
Example:
{{someMacro listParam=“val1, val2, val3”/}}
This is not possible in a wiki macro though.
Thanks
-Vincent
Macro code:
#set( $a = $xcontext.macro.params.array)
$a
#foreach($i in $a)
$i
#end
Page code:
#set( $array = ['Chapter 1', 'Chapter 2', 'Chapter 3'])
$array
#foreach($i in $array)
$i
#end
{{test array=$array/}}
The array processed in the page works as expected. The array passed to the macro only
prints up to the first space between Chapter and 1. I have also tried to enter the array
as a string which passes the string but the macro does not treat it as an array, which
doesn’t surprise me. The comments from Stefan and Vincent on
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WikiMacroTutorial seem to touch on this
issue but I do not understand the answer provided. Thank you for any clarification to this
issue you can provide.
Regards,
Jesse Bright
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users