1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | from django import template
register = template.Library()
def format(value, arg):
"""
Alters default filter "stringformat" to not add the % at the front,
so the variable can be placed anywhere in the string.
"""
try:
if value:
return (unicode(arg)) % value
else:
return u''
except (ValueError, TypeError):
return u''
register.filter('format', format)
|
More like this
- Link filter by sean2000 5 years, 5 months ago
- Simple template tag to do |stringformat filter with format from a variable by leopd 2 years, 1 month ago
- Functional Filters by waterson 5 years, 7 months ago
- Url filter middleware by limodou 6 years, 2 months ago
- Export Models by brunobord 4 years, 11 months ago
Comments