Skip to Content
Mastering Flask Web Development - Second Edition
book

Mastering Flask Web Development - Second Edition

by Daniel Gaspar, Jack Stouffer
October 2018
Intermediate to advanced
332 pages
8h 9m
English
Packt Publishing
Content preview from Mastering Flask Web Development - Second Edition

The truncate filter

The truncate filter takes a long string, returns a string cutoff at the specified length in characters, and appends an ellipsis, as shown in the following code:

{{ "A Longer Post Body Than We Want" | truncate(10) }} 
A Longer... 

By default, any words that are cut in the middle are discarded. To disable this, pass True as an extra parameter as follows:

{{ "A Longer Post Body Than We Want" | truncate(10, True) }} 
A Longer P... 
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Flask Web Development, 2nd Edition

Flask Web Development, 2nd Edition

Miguel Grinberg
Flask Web Development

Flask Web Development

Miguel Grinberg

Publisher Resources

ISBN: 9781788995405Supplemental Content