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>
This commit is contained in:
Dan McGee 2012-03-24 13:01:17 -05:00
parent 3e2e4d4ef8
commit 965351e85b
2 changed files with 13 additions and 0 deletions

View File

View File

@ -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: