最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - EJS doesn't escape characters - Stack Overflow

programmeradmin0浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论