Cradle/Express/EJS将html转换为其实体

Dmi*_*rin 1 ejs node.js express cradle

我在我的博客上使用Cradle with 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);
    });
});
Run Code Online (Sandbox Code Playgroud)

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>
<% } %>
Run Code Online (Sandbox Code Playgroud)

"res"变量是具有"content"字段(具有html)的对象的数组.但在渲染后,"str"将"quotes [i] .value.quote"符号转换为其实体,比如说to to< br>