node.jsejslocomotivejs

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?


Solution

  • You need this construct:

    <%- title %>
    

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