summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-03-24 19:01:17 +0100
committerDan McGee <dan@archlinux.org>2012-03-24 19:01:17 +0100
commit965351e85b25d83c193fcf68e42947b3b22a6b8f (patch)
tree09249bacc0ce1fb6deeac579c5474246f62c3735
parent3e2e4d4ef8910351910d633d17f8b4e9c0ea4c74 (diff)
downloadarchweb-965351e85b25d83c193fcf68e42947b3b22a6b8f.tar.gz
archweb-965351e85b25d83c193fcf68e42947b3b22a6b8f.tar.xz
Add retro_static template tag
Unfortunately {% static %} cannot interpret any context variables passed into it, so we need to customize things in order to use it here since our resources are sorted by year. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--retro/templatetags/__init__.py0
-rw-r--r--retro/templatetags/retro.py13
2 files changed, 13 insertions, 0 deletions
diff --git a/retro/templatetags/__init__.py b/retro/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/retro/templatetags/__init__.py
diff --git a/retro/templatetags/retro.py b/retro/templatetags/retro.py
new file mode 100644
index 0000000..c7fd9f0
--- /dev/null
+++ b/retro/templatetags/retro.py
@@ -0,0 +1,13 @@
+from django import template
+from django.contrib.staticfiles.storage import staticfiles_storage
+
+register = template.Library()
+
+
+@register.simple_tag
+def retro_static(year, path):
+ """Like the built-in {% static %} tag but with a little extra magic."""
+ full_path = "%s/%s" % (year, path)
+ return staticfiles_storage.url(full_path)
+
+# vim: set ts=4 sw=4 et: