In one of my FreeMarker templates I have a pair of macros which look something like this
<#macro RepeatTwice><#nested 1><#nested 2></#macro>
<#macro Destinations>
<#assign DestinationList = []>
<@RepeatTwice ; Index>
<#assign City == some XPath expression dependant on the index>
<#if City == something>
<#assign DestinationList = DestinationList + ["some string"]>
<#elseif City == something else>
<#assign DestinationList = DestinationList + ["some string"]>
</#if>
</@>
</#macro>
So now, my destination list contains 2 values. This works in that if I insert ${DestinationList[0]} or ${DestinationList[1]} before </#macro> I get the expected output.
My question is --- in a separate template I would like to capture the whole of the list from this macro so that I can access its elements as and when I need them.
For this I need the macro to return the whole list, not just an element from it.
But inserting ${DestinationList} or just DestinationList returns an error.
I have tried doing things like ${DestinationList[0,1]} and the like but nothing seems to work.
Is this possible?
Thanks,
Basil