Reputation: 152697
how to use HTML with JSON with Gulp-data ? I'm using it in a static website building process with Gulp, Nunjucks and MJML
JSON
{
message:"Welcome to <span class='red'>world</span>"
}
.nunjucks file
{{ message }}
is giving this output in final HTML output
Welcome to <span class='red'>world</span>
Upvotes: 0
Views: 1935
Reputation: 46
Looks like Nunjucks uses autoescaping: true
by default (due to their docs).
gulp-nunjucks-render
uses envOptions
to configure template engine (line 20 of its code).
You can try to pass autoescaping: false
in options in gulp to disable escaping (more info in readme).
Or you can just use {{ message | safe }}
in your template to disable escaping for one piece of code. Mode info in API Docs: Autoescaping
Upvotes: 3