Minify JS template tag

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from django import template
from jsmin import jsmin

register = template.Library()

class MinifyJs(template.Node):
    def __init__(self, nodelist):
        self.nodelist = nodelist
    def render(self, context):
        return jsmin(self.nodelist.render(context))

def minifyjs(parser, token):
    nodelist = parser.parse(('endminifyjs',))
    parser.delete_first_token()
    return MinifyJs(nodelist)

minifyjs = register.tag(minifyjs)

More like this

  1. Unobtrusvie Foldable Admin Interface by whiteinge 5 years, 4 months ago
  2. Template tags to integrate with modconcat by matthanger 3 years, 10 months ago
  3. Template tag for compressed CSS & JS (GAE version) by jeffar 4 years, 10 months ago
  4. YUI Loader as Django middleware by akaihola 5 years, 1 month ago
  5. Search Docs with Shortwave by baumer1122 4 years, 10 months ago

Comments

(Forgotten your password?)