简体   繁体   中英

NodeJS Ejs Variable Render HTML

You can output variables using ejs like so

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

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

However I tried including html in the variable and it just displays it as text. Is it possible to make it render as html?

You need this construct:

<%- title %>

That won't escape the contents of the title variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM