wordwrap Filter

String

Argument: n (required) – the number of characters per line.

Documentation

Implements word wrapping by inserting a newline character every n characters. Useful for plain text, but not typically for HTML.

Variable

blurb_text = 'You are pretty smart!'

Template

{{ blurb_text|wordwrap:10 }}

Result

You are
pretty
smart!

In a browser, whitespace is condensed, so the output would be:

You are pretty smart!

Commentary

Useful for plain text, but not typically for HTML.


Did we get something wrong? Is there a use case for the wordwrap filter that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on Sept. 16, 2020, 7:34 p.m. EST