What you need to keep in mind is that {{test}} is wiki syntax, it's not a Velocity/Java API. You print it with Velocity, you don't call it. So this is all text until the wiki parser parses it, to pass an array you need to serialize it with the right syntax.
A good way to understand and debug that is to disable wiki parsing in your Velocity macro as in {{velocity wiki="false"}}. This will gives you exactly what the wiki parser gets in input. The problem you have in your example is that you end up with something like: {{test array=[Chapter 1, Chapter 2, Chapter 3]/}} and indeed without "" the parser will start at first white space it hits. All that is mostly for Java based macros (1). One limitation of wiki based macros is that they don't have any automatic parameters conversion and they just get all parameters as String, then you parse it in your macro content (see http://jira.xwiki.org/browse/XWIKI-13282). 1: http://rendering.xwiki.org/xwiki/bin/view/Main/ExtendingMacro On Sun, Apr 3, 2016 at 2:02 AM, Personal <je...@abrightfamily.com> wrote: > Is it possible to pass an array as a macro parameter? So far my attempts have > failed. > > 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@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users -- Thomas Mortagne _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users