> On 03 Apr 2016, at 02:02, Personal <[email protected]> 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
[email protected]
http://lists.xwiki.org/mailman/listinfo/users