tofutim
tofutim

Reputation: 23394

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?

Upvotes: 66

Views: 42891

Answers (2)

agent-j
agent-j

Reputation: 27943

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

p!= aVarContainingHTML

Pug Doc

Upvotes: 138

akardon
akardon

Reputation: 46036

The syntax you need is :

!{yourJsVariable}

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

Upvotes: 57

Related Questions