How to store html in mysql database and retrieve it as html in nodejs app?

Viewed 431

Suppose I store <b>bold text</b> in mysql column then I should get it as bold text And not as, <b>bold text</b>

I am using it in a nodejs app and using handlebars as view engine.

2 Answers

To display html with your handlebars template, you'll need to use {{{variable}}} not {{variable}} (replace 'variable' with your actual variable name.)

If you wanted to inject a string into the DOM, you can do that pretty simply with innerHTML.

app.innerHTML = '<b>bold text</b>';
Related