Question

I'm using Cradle with Express and EJS on my blog. Maybe i am missing smth but some of them converts html entities to its equivalents.

I have html in doc.quote field and after this piece of code it changes

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" variable is array which has objects with "content" field (which has html). But after rendering "str" has "quotes[i].value.quote" symbols converted to its entities, say <br> to &lt ; br &gt ;

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top