If I use
{{ post.body_html | safe }}
program will select data from MySQL and display on browser as complete article. So does jinja2 have filter help show part of variable like article's first paragraph.
If I use
{{ post.body_html | safe }}
program will select data from MySQL and display on browser as complete article. So does jinja2 have filter help show part of variable like article's first paragraph.
You can use the
truncate()
filter. You can send to it as argument the number of characters you want to show in your template:Obviously you can code a function (in your python file) which detects the first paragraph, counts the number of characters and send this number (that it returns) to your
truncate()
filter in your template.