diff options
-rw-r--r-- | main/templatetags/__init__.py | 0 | ||||
-rw-r--r-- | main/templatetags/cdn.py | 19 |
2 files changed, 19 insertions, 0 deletions
diff --git a/main/templatetags/__init__.py b/main/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/main/templatetags/__init__.py diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py new file mode 100644 index 0000000..090355b --- /dev/null +++ b/main/templatetags/cdn.py @@ -0,0 +1,19 @@ +from django import template +from django.conf import settings + +register = template.Library() + +@register.tag +def jquery(parser, token): + return JQueryNode() + +class JQueryNode(template.Node): + def render(self, context): + version = '1.4.1' + if getattr(settings, 'DEBUG', True): + jquery = '/media/jquery-%s.min.js' % version + else: + jquery = 'http://ajax.googleapis.com/ajax/libs/jquery/%s/jquery.min.js' % version + return '<script type="text/javascript" src="%s"></script>' % jquery + +# vim: set ts=4 sw=4 et: |