Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jade: escape html in mixin argument

Tags:

javascript

pug

What I've tried:

mixin simpleDivInject(text)
    div 
        h1 #{text}


mixin simpleDivInject("line one <br/> line two")

Desired outcome

<div>
    <h1>line one <br/> line two</h1>
</div>

The actual outcome

<div>
    <h1>line one &lt;br/&gt; line two</h1>
</div>

How can I achieve the desired outcome. I have tried a few more things (such as storing the string in a var ect.), but no luck so far.

like image 872
Fresheyeball Avatar asked Oct 25 '12 00:10

Fresheyeball


1 Answers

Actually I just figured it out. Answering here in the hopes it is helpful to someone else down the line. The escaping is not occurring in the mixin argument system, but in the vinilla jade system, so:

mixin simpleDivInject(text)
    div 
        h1!= text


mixin simpleDivInject("line one <br/> line two")

Solves the problem

like image 104
Fresheyeball Avatar answered Sep 21 '22 22:09

Fresheyeball