Wrappable text

 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

  1. Make a string a fixed-width by adamfast 4 years, 8 months ago
  2. Table of Contents by dogada 4 years, 2 months ago
  3. Avoid widows using a template filter by jcroft 4 years, 11 months ago
  4. Frequently used tags/filters for Jinja2 by mathwizard 3 years, 4 months ago
  5. convert plain text to html by limodou 4 years, 11 months ago

Comments

(Forgotten your password?)