问题
I have a problema with Jade, I take an unescaped string from db (something like this:
"<mo>&"
this string can contain some html code, I pass the string to the page with
res.render('page',f(){})
from the layout I stamp the string with !{t.text} but the html code is not rendered, seems that prints plain text. where is the error?
回答1:
I've set up default
express
app which usesjade
as its template engine.Modified
routes -> index.js
to pass some encoded text
router.get('/', function(req, res) {
res.render('index', { title: 'Express', encodedText: '<mo>&' });
});
- Modified
views -> index.jade
to display this text
block content
h1= title
p Welcome to #{title}
p Encoded text !{encodedText}
- Result seems to be OK

来源:https://stackoverflow.com/questions/27888764/jade-html-escaped-string