diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-15 02:20:23 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-15 02:20:23 +0200 |
commit | ef61eacd08b678b55eeaacfd5cc29ada37662e10 (patch) | |
tree | 78a60ba8908684abbf0951be4b9d0f3ad0d03457 | |
parent | f252aede11319c694f3a81626b996403eb14444f (diff) | |
download | archweb-ef61eacd08b678b55eeaacfd5cc29ada37662e10.tar.gz archweb-ef61eacd08b678b55eeaacfd5cc29ada37662e10.tar.xz |
Simplify jQuery CDN tag
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | main/templatetags/cdn.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py index 83ee61f..1923af8 100644 --- a/main/templatetags/cdn.py +++ b/main/templatetags/cdn.py @@ -3,21 +3,16 @@ from django.conf import settings register = template.Library() -@register.tag -def jquery(parser, token): - return JQueryNode() - -class JQueryNode(template.Node): - def render(self, context): - prefixes = { False: 'http', True: 'https' } - version = '1.4.3' - oncdn = getattr(settings, 'CDN_ENABLED', True) - if oncdn: - jquery = 'https://ajax.googleapis.com/ajax/libs/jquery/' \ - '%s/jquery.min.js' % version - else: - jquery = '/media/jquery-%s.min.js' % version - return '<script type="text/javascript" src="%s"></script>' % jquery +@register.simple_tag +def jquery(): + version = '1.4.3' + oncdn = getattr(settings, 'CDN_ENABLED', True) + if oncdn: + link = 'https://ajax.googleapis.com/ajax/libs/jquery/' \ + '%s/jquery.min.js' % version + else: + link = '/media/jquery-%s.min.js' % version + return '<script type="text/javascript" src="%s"></script>' % link @register.tag def cdnprefix(parser, token): |