Reputation: 148
I'm trying to send html string as a res.render()
parameter and render it as html in the client-side. How do I get the browser to recognize it as html instead of just as a string? Can this be done?
home.hbs
<div id="results">
{{#each results}}
<p>{{this}}</p>
{{/each}}
</div>
server.js
app.get('\', (req,res) => {
let results = ['<mark>This</mark> is highlighted.']
res.render('home', {results: results});
})
In my webpage, I want it to look like a paragraph where the word 'This' is highlighted (because of <mark>
) but instead it shows up as <mark>This</mark> is highlighted.
where This
is not highlighted and the mark tags are plain text.
Upvotes: 1
Views: 433
Reputation: 401
use "triple-stash" to cancel html escape functionality.
https://handlebars-lang.github.io/docs/guide/#html-escaping
Upvotes: 1