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
}
对的,这是可能的
var arr=[<#list messages.thread.messages.topic as message>${message.body},</#list>]
Yes it is possible. You need to arrange that your Freemarker template generates a Javascript array literal and assigns it to the appropriate Javascript variable. Start with the syntax of a Javascript array literal and then figure out how to generate one using Freemarker constructs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.