diff options
author | Dan McGee <dan@archlinux.org> | 2010-02-27 21:12:14 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-02-27 21:12:14 +0100 |
commit | 680ddeb0894df7d0e6939d9fc6d542ee1c585817 (patch) | |
tree | c789d21a9200786957bc1af9a250bf15c55fa809 /main | |
parent | a70a3a04c70f27d2dd95b74c13264909d15a0e2e (diff) | |
download | archweb-680ddeb0894df7d0e6939d9fc6d542ee1c585817.tar.gz archweb-680ddeb0894df7d0e6939d9fc6d542ee1c585817.tar.xz |
Add CDN templatetag package
For now, this contains one new template tag- 'jquery'. This will allow us to
use the Google AJAX CDN in non-debug environments, since there is really no
need for us to be the source of this common file. In the future this package
may gain other static media resource tags as well.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-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: |