【发布时间】:2011-11-16 22:56:17
【问题描述】:
我在我的博客上使用 Cradle 和 Express 和 EJS。也许我错过了 smth 但其中一些将 html 实体转换为其等价物。
我在 doc.quote 字段中有 html,在这段代码之后它发生了变化
quotesDb.view('list/by_date', {
'startkey' : {},
'endkey' : null,
'descending' : true
}, function(err, res) {
if (err) {
r.send();
return;
}
r.partial('quotes', {'quotes' : res}, function(err, str) {
console.log(str);
sendResponse('content', str);
});
});
quotes.ejs:
<% for (var i=0; i<quotes.length; i++) { %>
<div>
<%=quotes[i].value.quote%>
</div>
<div class="date">
<%=(new Date(quotes[i].value.ts*1000)).toLocaleDateString()%><% if (quotes[i].value.author) { %>, <%=quotes[i].value.author%><% } %>
</div>
<% } %>
“res”变量是数组,其中包含带有“content”字段(具有 html)的对象。但是在渲染“str”之后,将“quotes[i].value.quote”符号转换为它的实体,比如
到 < ; br>
【问题讨论】:
-
绝对是 EJS。问题是:如何让它呈现数据而不将其转换为实体。
标签: node.js express ejs cradle