How do I compile mutliple HTML Jade templates that use the same mixin

167 views Asked by At
mixin hero(title)
    .hero
        .hero__inner
            h1.hero__title #{title}

So, my project uses a Jade mixin like the above on multiple pages and, when I compile the Jade to HTML pages, I have to copy that mixin on each page that it is used.

I can compile the pages using either grunt-jade or grunt-jade-contrib, but does anyone know how to use those modules (or any others) to globally pass that mixin to all pages so I don't have to copy it everytime?

1

There are 1 answers

0
Zlatko On BEST ANSWER

Why not simply include it?

include ../partials/hero.jade
+hero('My title')

Include the file on all pages you need it at. And there are even plugins that can automatically detect and insert this stuff for you.