question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Including External Mixins

See original GitHub issue

Mixins defined in a file are not correctly imported when the file is included in a larger template. eg:

helper.jade:

mixin foo()
  p test

master.jade:

include helper
mixin foo()

will throw an error that foo is undefined unless foo is manually imported via raw jinja syntax eg:

master.jade:

{% from 'helpers.jade' import foo %}
mixin foo()

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
chrishainescommented, Jan 14, 2013

@SyrusAkbary is this because of the jade specification?
This would seem to suggest otherwise: http://tjholowaychuk.com/post/7590787973/jade-mixins-includes

0reactions
damoxccommented, Oct 20, 2013

This can be fixed to some extent for the mako compiler, although I’m not 100% sure on the full ramifications of the change, I just know it fixes my particular use case.

diff --git a/pyjade/ext/mako.py b/pyjade/ext/mako.py
index 0bdf27c..1f4c428 100644
--- a/pyjade/ext/mako.py
+++ b/pyjade/ext/mako.py
@@ -52,7 +52,7 @@ class Compiler(_Compiler):
     def visitInclude(self,node):
         path = self.format_path(node.path)
         self.buffer('<%%include file="%s"/>'%(path))
-
+        self.buffer('<%%namespace file="%s" import="*"/>'%(path))

     def visitConditional(self,conditional):
         TYPE_CODE = {
Read more comments on GitHub >

github_iconTop Results From Across the Web

css - How to include @mixin from one sass file to another sass ...
This is the file where I am importing the mixin: action-sheet-layout-1 { @include '../../../theme/main ...
Read more >
mixin and @include - Sass
Mixins allow you to define styles that can be re-used throughout your stylesheet. They make it easy to avoid using non-semantic classes like...
Read more >
How to import Sass/SCSS mixins global? - DEV Community ‍ ‍
scss files in the App.js so I can access the classes/mixins/variables global. But only the classes are accessible. So for example using a...
Read more >
Can't @use mixin, but can @import · Issue #2858 · sass/sass
I have a top-level file that only has: @mixin bg_img($path) { background-image: ... so you'd want to @include mixins.bg_img .
Read more >
Sass @mixin and @include - W3Schools
Sass Mixins. The @mixin directive lets you create CSS code that is to be reused throughout the website. The @include directive is created...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found