Flask Snippets

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:

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

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