jinja2 template char limit

55 views
Skip to first unread message

sadaf2605 via StackOverflow

unread,
Feb 28, 2013, 5:11:53 AM2/28/13
to google-appengin...@googlegroups.com

in {{blog.content}} I want to limit the viewer to see only 50 char at most, how can I do that using jinja2?

After searching through their documentation I have found that {{ s|autolink[ length[ nofollow]] }} has a length property but it will make it auto link! Which I don't want it to be.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/15132702/jinja2-template-char-limit

Paul C via StackOverflow

unread,
Feb 28, 2013, 5:26:53 AM2/28/13
to google-appengin...@googlegroups.com

Have you tried the python slice notation? Not sure if it would work offhand and can't test right now but:

{{ blog.content[:50] }}


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/15132702/jinja2-template-char-limit/15133071#15133071
Reply all
Reply to author
Forward
0 new messages