Flask Snippets

Enable jinja2 line statements

By Jason Orendorff 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.