Search code examples
htmlexpresshandlebars.jstemplate-engineexpress-handlebars

Handlebars - Compile passed parameter (containing HTML) to template engine


I use expressjs and hbs(Handlebars) as the template engine. One of the parameters that are passed to the template when loading the page contains HTML code. When the page loads, instead of processing the parameter and displaying the elements, it is displayed as text. How can I solve this?

//Server-side:
let parameter = "<h2 id="how-to-use">How To Use</h2>";

//HTML:
<div id="container">{{parameter}}</div>

//--------------------------------------

//result after page load
<h2 id="how-to-use">How To Use</h2>

//Instead of
How To Use

Solution

  • got it. use the triple {{{ }}} brackets