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