Basically I need a javascript array built from a channel, but as we all know curly braces can be an issue, I was just wondering if there is a way to make a javascript array in an EE template. Something like this:

var locationArray = [

{ xpos : 0.08, ypos : 0.07, title : "Location No. 1", image: "location1.jpg", text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ac pharetra est, vel efficitur orci. Mauris euismod, sapien eget pretium viverra, lacus erat gravida sapien, at tempus ante nisi sed odio."},

{ xpos : 0.50, ypos : 0.50, title : "Location No. 2", image: "location2.jpg", text: "Mauris sodales lectus eu sem congue, eu malesuada est accumsan. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque dui ligula, sodales porta libero in, tincidunt posuere odio."},

{ xpos : 0.65, ypos : 0.32, title : "Location No. 3", image: "location3.jpg", text: "Nunc dignissim porttitor leo in aliquam. Morbi malesuada mauris in velit cursus ornare. In hac habitasse platea dictumst. Praesent non congue sapien."} 


2 Answers 2


Haven't tried it, but you might get away with constructing your output within an EE template replacing the curly brackets with { and }, and then putting all the output within a streeng tag pair to decode it ...

{exp:streeng decode="yes"}
... javascript array written using html entities rather than { and }
  • That seems like a wonky way to do it
    – The Hawk
    Dec 22, 2016 at 15:42

There is a detailed post from 2011 that seems to cover some of the issues and work arounds that should help you:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.