NodeJS Ejs变量呈现HTML

时间:2013-05-09 18:56:05

标签: node.js ejs locomotivejs

你可以使用像这样的ejs输出变量

PagesController.test = function() {
  this.title = 'test'
  this.render();
}

<title><%= title %></title>

但是我尝试在变量中包含html,它只是将其显示为文本。是否可以将其渲染为html?

1 个答案:

答案 0 :(得分:3)

你需要这个结构:

<%- title %>

这不会逃避title变量的内容。