Search code examples
pug

Can i use tags in mixin in pug?


How i can use tag in variable in mixin in pug?

mixin crblock(img, title)
  figure.cr-block
    .cr-block--img
      img(src=img, alt="")
    figcaption.cr-block--caption= title

+crblock('img/carelist/z1.svg', 'Text <br> text')

Solution

  • I believe you meant an HTML tag (<br> in this case) when you mentioned 'tag'.

    For which, you need to use escaping in the PUG syntax. You may use the != operator or the !{} operator for the same.

    figcaption.cr-block--caption!= title
    

    or

    figcaption.cr-block--caption !{title}
    

    Tested using http://naltatis.github.io/jade-syntax-docs/#escaping.

    Hope this helps.