hh54188
hh54188

Reputation: 15626

The jade template can't render content that have html tag?

My jade template is

div.article
 #{content}

the content is <p>Sample Test</p>

so the render result should be

<div class="article">
  <p>Sample Text</p>
</div>

but the render result is

   <div class="artichle">
    <<p>Sample Text</p>></<p>Sample Text</p>>
   </div>

Why this happened? How can I render the content with html tag correctly?

Upvotes: 0

Views: 2233

Answers (1)

Guy
Guy

Reputation: 598

Use the unescaped variant of tag texts :

- var html = "<script></script>"
| !{html}    

See https://github.com/visionmedia/jade#tag-text for the full explanation

In your example you would write :

div.article
  !{content}

Notice that you should be careful with injecting html unescaped code. It may contain cross-site hacks depending on your use case (injecting a redirect in a comment)

Upvotes: 7

Related Questions