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:
parent
3e2e4d4ef8
commit
965351e85b
0
retro/templatetags/__init__.py
Normal file
0
retro/templatetags/__init__.py
Normal file
13
retro/templatetags/retro.py
Normal file
13
retro/templatetags/retro.py
Normal 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:
|
Loading…
Reference in New Issue
Block a user