admin管理员组

文章数量:1305584

I have a Node JS server querying MongoDB, and then render the returns to an EJS template:
res.render('graphFabric.ejs', {'iBeacons':[(beacon)]});.
When I try to recover the JSON from my template using <%=iBeacons%> , ' (single quotes) appear as &#39; For example: udid: &#39;b9407f30f5f8466eaff925556b57fe6d&#39;,
How is it possible to fix this issue since it breaks my JSON structure?

I have a Node JS server querying MongoDB, and then render the returns to an EJS template:
res.render('graphFabric.ejs', {'iBeacons':[(beacon)]});.
When I try to recover the JSON from my template using <%=iBeacons%> , ' (single quotes) appear as &#39; For example: udid: &#39;b9407f30f5f8466eaff925556b57fe6d&#39;,
How is it possible to fix this issue since it breaks my JSON structure?

Share Improve this question edited Dec 3, 2018 at 16:15 Cœur 38.8k26 gold badges205 silver badges277 bronze badges asked Jul 1, 2015 at 14:32 Zack SZack S 1,4421 gold badge23 silver badges38 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

Figured from https://github./tj/ejs/tree/0.8.3#features that I was using:
Escapes html by default with <%= code %> when I should have used
Unescaped buffering with <%- code %>
**Replacing = with - fixed the problem

本文标签: javascriptEJS doesn39t escape charactersStack Overflow