I am using the Forms library for Node.js (Forms), which will render a form for me on the backend as so:
var signup_form = forms.create({
username: fields
The new ejs (v2, v2.5.7) development is happening here: https://github.com/mde/ejs The old ejs (v0.5.x, 0.8.5, v1.0.0) is available here https://github.com/tj/ejs
Now with ejs you can do even more. You can use:
<%= %>
(escape function configurable)<%- %>
-%>
ending tag<%_ _%>
<% %>
So, in your case it is going to be <%- variable %>
where variable
is something like
var variable = "text here <br> and some more text here";
I hope this helps someone.
With EJS you can have several tags:
<% code %>
... which is code that is evaluated but not printed out.
<%= code %>
... which is code that is evaluated and printed out (escaped).
<%- code %>
... which is code that is evaluated and printed out (not escaped).
Since you want to print your variable and NOT escape it, your code would be the last type (with the <%-
). In your case:
<%- my_form_content %>
For more tags, see the full EJS documentation
I had the same issue with rendering the textarea input from from a wysiwyg editor saved as html in my database. The browser will not render it but displayed the html as text. After hours of searching, I found out
<%= data %>
escaped data while
<%- data %>
left data 'raw'(unescaped) and the browser could now render it.