1 2 3 4 5 6 7 8 9 10 | @stringfilter
def wrappable(value):
"""
Places zero-width breaking spaces in text to allow it to wrap at any point.
Munges text into HTML, so should be used last in the filter chain.
{{ user_generated_text|wrappable }}
"""
return "​".join(value)
register.filter('wrappable', wrappable)
|
More like this
- Filter to add zero-width space to break up long words by jayliew 8 months, 1 week ago
- Avoid widows using a template filter by jcroft 6 years, 3 months ago
- Inline truncate by character number by esanchez 4 years, 10 months ago
- Truncate text to length up until the nearest space by phektus 2 years, 2 months ago
- Resize image on save by David 5 years, 1 month ago
Comments