Rendering HTML in variable using Jade


I have some text stored in a variable which contains some HTML. For example, the <b>cat</b> in the hat. However, when I render it in Jade, it shows up with the tags instead of rendering the formatting. How can I fix this?

4/12/2018 3:45:12 AM

Accepted Answer

Code buffered by = is escaped by default for security, however to output unescaped return values you may use !=

p!= aVarContainingHTML

Pug Doc

5/9/2018 5:07:53 PM

The syntax you need is :


if you use #{yourJsVariable} it shows < >, but with !{} it doesn't.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow