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
- Sending html emails with images using Django templates by sleytr 5 years, 11 months ago
- Generic model filter from request GET data by genbit 1 year, 9 months ago
- linebreaksli template filter by rokclimb15 5 years, 11 months ago
- testdata tag for templates by showell 4 years ago
- icon shortcut - pseudohtml tag with attribute merging and variables resolving by wiz 2 years, 11 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.
#