I am writing a JS array of objects in a Freemarker template. But I am having serious problems, not including the comma after the last element.
<#assign pages = module.pages.page> wh.pages = [ <#list pages as page> {"name" : "${ page.@name }", "href" : "${ page.@href }"} <#if (index+1) < pages?size>,</#if> </#list> ]
Therefore, while repeating the list, while the index + 1 is less than the length / size of the variable pages, it should write a comma. So when it is equal in size, it should omit the comma.
So how can this be achieved?
source share