jade html escaped string

a 夏天 提交于 2019-12-14 03:03:48

问题


I have a problema with Jade, I take an unescaped string from db (something like this:

"<mo>&amp"

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:


  1. I've set up default express app which uses jade as its template engine.

  2. Modified routes -> index.js to pass some encoded text

router.get('/', function(req, res) {
  res.render('index', { title: 'Express', encodedText: '<mo>&amp' });
});
  1. Modified views -> index.jade to display this text
block content
  h1= title
  p Welcome to #{title}
  p Encoded text !{encodedText}
  1. Result seems to be OK



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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!