Flask Snippets

Snippets are unofficial and unmaintained.

This is an archived view of user-submitted snippets. Despite being hosted on the Flask site, they are not official. No Flask maintainer has curated or checked the snippets for security, correctness, or design.

Enable jinja2 line statements

Posted by Jason Orendorff on 2012-09-29 @ 05:19 and filed in Template Tricks

Add this line of code right after creating your app:

app.jinja_env.line_statement_prefix = '%'

Then you can use a single % rather than {% %} in templates:

<ul>
  % for item in items
    <li>{{ item }}</li>
  % endfor
</ul>

This snippet by Jason Orendorff can be used freely for anything you like. Consider it public domain.