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. Create variables within templates by nkwenti 5 years, 10 months ago
  2. whitespaceoptimize block tag by peterbe 5 years, 7 months ago
  3. Severity codes in user messages by cconnell 5 years, 3 months ago
  4. Custom CSS class in Form with template tag filter by kegan 4 years, 10 months ago
  5. Add CSS class template filter by lazerscience 3 years, 5 months ago

Comments

(Forgotten your password?)