Created
August 15, 2023 16:53
-
-
Save allouis/8eba11f9778d93e0894ac2621621ab10 to your computer and use it in GitHub Desktop.
Handlebars.js escaping example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
var handlebars = require('handlebars'); | |
handlebars.registerHelper('html_returning_helper', function () { | |
return '<p>This is HTML</p>'; | |
}); | |
var template = handlebars.compile(` | |
{{#html_returning_helper}} {{/html_returning_helper}} | |
{{html_returning_helper}} | |
`); | |
var result = template({}); | |
assert(result === ` | |
<p>This is HTML</p> | |
<p>This is HTML</p> | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment