Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Line statements eat newlines #52

Closed
gavento opened this Issue · 3 comments

2 participants

@gavento

Line statements eat not only the spaces until the beginning of the line as documented at http://jinja.pocoo.org/docs/templates/#whitespace-control , but also all the previous newlines.

As of 2.7-dev, the following code generates no empty lines:

%% for i in range(3)
{{i}}, next line should be empty

%% endfor

This is an issue in languages where newlines matter (generated LaTeX).

@gavento

Can be fixed in lexer.py:200 by changing the regex from r'^\s*' to r'^[ \t\v]*'. This makes the whitespace list limited, but that should not be an issue without re.UNICODE or re.LOCALE

@aspiers

Hmm. There still needs to be a way of including blank lines in the code which do not get rendered in the output, but are only there for legibility. I propose that lines containing line_statement_prefix (or line_comment_prefix) and nothing else be the mechanism for this. Currently they are not handled in a helpful way (filed as #204 and #205).

@aspiers

Just discovered that {##} is a tolerable workaround.

@mitsuhiko mitsuhiko closed this in 08f38a8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.