I have a Freemarker sequence that looks like this:
{values:"Joe","Sally","Sue"}
I am trying to turn this into a Javascript array on the HTML page with the following code:
var myValues = ${values};
When I do this, I get a Freemarker templating error saying:
freemarker.core.NonStringOrTemplateOutputException: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a sequence (wrapper: f.t.SimpleSequence): ==> values [in template "my_page.html" at line 451, column 32]
The basic thing is how do I convert a Freemarker sequence to a Javascript array on the template.
Well, I did the following hack and it works so I am putting it here for any others who may need it:
var myValues = [<#if values??><#list values as v>${v},</#list><#else></#if>];
This then turned the Freemarker sequence into a Javascript array and works.