SASS/SCSS include template tag.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from django.template import Node
from django.template.base import Library
from django.template.loader_tags import do_include

from scss import Scss
sass = Scss()

register = Library()

class SASSNode(Node):
    def __init__(self, node):
        self.node = node

    def render(self, context):
        raw = self.node.render(context)
        return sass.compile(str(raw))

def sass_include(parser, token):
    return SASSNode(do_include(parser, token))

register.tag('include_sass', sass_include)

More like this

  1. Template tag to create a list from one or more variables and/or literals by davidchambers 2 years, 8 months ago
  2. Class-based coverage test runner by brutasse 2 years, 11 months ago
  3. Cacheable resources by jbrisbin 4 years, 9 months ago
  4. QRCode template tag by bradbeattie 6 months ago
  5. Custom CSS class in Form with template tag filter by kegan 3 years, 11 months ago

Comments

(Forgotten your password?)