Verbose template filter : avoid too many if
This tiny template filter saves you the tedious test "if this variable is set, print this text based on this variable". 'verbose' filter takes one parameter : a string containing '%s' which is a placeholder for the value to test. Check those examples : * Replace this : {% if name %} Hello {{ name }}, this is a dummy text {% endif %} * By this : {{ name|verbose:"Hello %s this is a dummy text" }} This is also usefull for HTML : {{ image|verbose:"<img src=\"%s\" />" }}
- template
- filter