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?
Asked
Active
Viewed 4.2k times
2 Answers
138
Code buffered by = is escaped by default for security, however to output unescaped return values you may use !=
p!= aVarContainingHTML

agent-j
- 27,335
- 5
- 52
- 79
-
4How can I do this for plain line of text (not a tag)? – Shamoon Dec 24 '15 at 21:29
-
Update: fresh link to documentation https://pugjs.org/language/code.html – pvolyntsev Aug 10 '17 at 04:47
-
Coulnd't find this on the official pug documentation. Did they leave it out? The section on interpolation is quite short, am I blind? Thanks anyways :) – atripes Nov 05 '17 at 01:30
57
The syntax you need is :
!{yourJsVariable}
if you use #{yourJsVariable}
it shows < >, but with !{}
it doesn't.

akardon
- 43,164
- 4
- 34
- 42
-
2Link to docs: https://pugjs.org/language/interpolation.html#string-interpolation-unescaped – cymruu Jun 22 '20 at 15:27