From 680ddeb0894df7d0e6939d9fc6d542ee1c585817 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 27 Feb 2010 14:12:14 -0600 Subject: 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 --- main/templatetags/__init__.py | 0 main/templatetags/cdn.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 main/templatetags/__init__.py create mode 100644 main/templatetags/cdn.py (limited to 'main') diff --git a/main/templatetags/__init__.py b/main/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/main/templatetags/cdn.py b/main/templatetags/cdn.py new file mode 100644 index 00000000..090355b7 --- /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 '' % jquery + +# vim: set ts=4 sw=4 et: -- cgit v1.2.3-54-g00ecf