1 2 3 4 5 6 7 8 9 10 11 12 13 | from django import template
register = template.Library()
@register.filter
def verbose(value, arg):
try:
if not value:
return ''
return arg % value
except Exception:
return str(value)
|
More like this
- Python-like string interpolation in Javascript by phxx 1 year, 7 months ago
- testdata tag for templates by showell 2 years, 9 months ago
- Front end admin toolbar by eallik 2 years, 2 months ago
- linebreaksli template filter by rokclimb15 4 years, 7 months ago
- Name Capitalize Filter by hotani 4 years, 9 months ago
Comments
Great idea.
#
perfect!
#
Good stuff, very handy. If used for HTML as in the last example, don't forget to tag on the |safe filter, too.
#