mitsuhiko/jinja2 — pull request #139 by kristi (2012-07-12 21:03:06+00:00)
Title: lstrip_blocks feature: Smarter whitespace control

Jinja's whitespace control using `{%-` and `-%}` is convenient, but tedious to apply to many blocks to get cleanly indented output.

The new `lstrip_blocks` option removes spaces and tabs from the beginning of a line up to a block tag. If there are characters other than spaces or tabs preceding the block tag, nothing is stripped. So the spaces would be removed from
```
{% set x = 1 %}
```
but not from
```
hello {% set x = 1 %}
```

Often, a block tag appears on its own line in a template. Using `lstrip_blocks` and the existing `trim_blocks` options, the entire tag line will be automatically removed when rendering a template.

Example template:

```

{% for post in posts %}

{{ post.title }}

{% endfor %}

```

The rendered output:

```

Post One

Post Two

Post Three

```