mitsuhiko / jinja2-htmlcompress

Compresses HTML in Jinja2 streams
Other
128 stars 27 forks source link

Unexpected space removal #8

Open webtic opened 10 years ago

webtic commented 10 years ago

The space between "firstcol" and "cell_style" gets removed when a conditional statement is in-between quotes.

Thus: <th class="{%if loop==1%}firstcol {% endif %} cell_style">

is compressed to:

<th class="firstcolcell_style">

instead of the expected

<th class="firstcol cell_style">

Obviously forcing a space saves the day but I wasn't expecting the removal.

<th class="{%if loop==1%}firstcol{{ " " }}{% endif %} cell_style">

eli-collins commented 7 years ago

My branch over in https://github.com/eli-collins/jinja2-htmlcompress has a rewritten parser that should take care of this issue; and added your same to the tests