Snippet List
Sometimes you have an uncontrolled amount of text in a horizontally constrained space.
The wrappable filter places zero-width breaking spaces into the given text so that it can wrap at any point, as necessary for the containing width. Sometimes better than eliding (chopping long text...) or cropping/scrolling overflow.
- template
- filter
- typography
Building on [jcroft's snippet](http://www.djangosnippets.org/snippets/17/), here's a slightly more advanced version which has two filters, one for basic text and the other for html snippets.
Usage is like so:
<h2>{{ blog_entry.headline|escape|widont }}</h2>
{{ blog_entry.html|widont_html }}
On top of Jeff's reasons for using these filters, they are important because they help keep one of [God's commandments](http://www.ebible.com/bible/NIV/Exodus+22%3A22). ;)
- filter
- widows
- typography
- widont
**Support good typography! Avoid widows! **
"Widows" are single words that end up on their own line, thanks to automatic line-breaks. This is an no-no in graphic design, and is especially unsightly in headers and other short bursts of text. This filter automatically replaces the space before the last word of the passed value with a non-breaking space, ensuring there is always at least two words on any given line. Usage is like so:
{{ blog.entry.headline|widont }}
It's a simple tag, but good typography is one of the hallmarks of a well-designed site that separates it from amateurish counterparts.
Note: The idea and name "widont" is copped directly from [Shaun Inman](http://shauninman.com), who wrote a [similar feature for WordPress](http://www.shauninman.com/archive/2006/08/22/widont_wordpress_plugin).
- filter
- widows
- templatetag
- typography
- shauninman
- widont
4 snippets posted so far.