cleat_list
Clear list from unwanted elements, within django template.
- template
- filter
- list
- clear
Clear list from unwanted elements, within django template.
I know in Django 1.2 we may acquire the same result using {% if value in arg %} but I need this filter in Django 1.1.
In one situation I needed to join strings in template, so I wrote this filter. Use it like this: 1) var = 23 {{"I have eat %d apples today."|joinstrings:var}} -> "I have eat 23 apples today." var = '23' {{"I have eat %s apples today."|joinstrings:var}} -> "I have eat 23 apples today." 2) var = [23, 45] #or any iterable object (except string - see pt. 1) {{"I have eat %d apples and %d pears today."|joinstrings:var}} -> "I have eat 23 apples and 45 pears today."
Tomek has posted 3 snippets.