handlebars-lang / handlebars.js

Minimal templating on steroids.
http://handlebarsjs.com
MIT License
17.82k stars 2.04k forks source link

How to escape {{}}. #1915

Closed yihchu closed 1 year ago

yihchu commented 1 year ago

After

var template = Handlebars.compile(document.getElementById('template').innerHTML);
let newTemplate = template({name: 'Max', age: 38});
document.getElementById('output').innerHTML = Handlebars.compile(newTemplate)({name: 'Max', age: 38});

all {{}} will be replaced. But if there is a situation, that i just want {{name}} show on the page rather than Max. How to do. I have tried a lot but can not find a way.

Please check: https://jsfiddle.net/ba8y9rwz/1/