FREEMARKER:避免转义HTML字符 [英] FREEMARKER: avoid escaping HTML chars

查看:860
本文介绍了FREEMARKER:避免转义HTML字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

freemarker输出出现问题...

Having a problem with freemarker output...

                [#assign optionsHTML = ""]                    
                [#list data as item]
                    [#assign optionsHTML = optionsHTML + '<option value="' + item.value +'>'+ item.label + '</option>' /]
                [/#list]

所以,如果我这样做

<select>
${iptionsHTML}
</select>

otions的输出获取的是html实体,而不是实际的html....

the output from otions get html entities instead of actual html.... so

&lt;option value=&quot .....

即使我这样做

            [#assign optionsHTML = ""]                    
            [#list data as item]
                [#noescape]
                [#assign optionsHTML = optionsHTML + '<option value="' + item.value +'>'+ item.label + '</option>' /]
                [/#noescape]
            [/#list]

甚至尝试

<select>
${iptionsHTML?html}
</select>

但更糟糕的是:(

推荐答案

因此,尝试了一些东西之后,我不知道之前做错了什么,但是很干净,这种方式很有效

So after trying stuff, I don't know what I've done wrong before, but clean, this way is working

[#assign optionsHTML = ""]                    
[#list data as item]
   [#assign optionsHTML = optionsHTML + '<option value="' + item.value +'>'+ item.label + '</option>' /]
[/#list]



<select>
   [#noescape]
   ${optionsHTML}
   [/#noescape]
</select>

这篇关于FREEMARKER:避免转义HTML字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆