I have a file includes/mixins.pug
that has some mixins. I also have a main layout file layouts/default.pug
that I am extend
-ing. How can I include those mixins in my layout file so that I don't have to write include includes/mixins
on every page?
For example, this is what I have to do for each additional pug file. In this case: new_page.pug
extends layouts/default
include includes/mixins
block content
+my_mixin('Hello World')
layouts/default.pug
doctype html
html(lang=$localeName)
block vars
head
meta(charset="UTF-8")
meta(http-equiv="X-UA-Compatible" content="IE=edge")
meta(name="viewport" content="width=device-width, initial-scale=1.0")
block styles
link(rel="stylesheet" type="text/css" href="/assets/css/styles.min.css")
body
block content
How do I include the mixins in layouts/default.pug
? I had trouble finding a solution in the documentation.
You can include
the mixins higher up in the view inheritance hierarchy, for example at the top of layouts/default.pug
. The mixins will then be available in the scope of all children views.
include includes/mixins
doctype html
html(lang=$localeName)
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With