freemarkerhtml-escape-characters

FREEMARKER: avoid escaping HTML chars


Having a problem with freemarker output...

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

so, if I do

<select>
${iptionsHTML}
</select>

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

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

even if I do

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

tried even

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

but's even worse :(


Solution

  • 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>