Assigning free marker list to a Javascript Array

rozar picture rozar · Dec 27, 2011 · Viewed 9k times · Source

Is it possible to assign a freemarker list to a Javascript Array? Does any other technique exist to achieve the same?

Suppose I have the following code

<#list messages.thread.messages.topic as message>
<div id="subject">${posts.subject}</div>
<div id="teaser">${posts.teaser}</div>
<div id="body">${message.body}</div>
</#list>

function script(){
   //I want to access the free marker list message here
}

Answer

rozar picture rozar · Dec 28, 2011

Yes it is possible

var arr=[<#list messages.thread.messages.topic as message>${message.body},</#list>]