Hi,
On 2/27/11 2:01 AM, Tomas Gavenciak wrote:
This is because of line 552 in lexer.py:
source = '\n'.join(unicode(source).splitlines()) (*)
I believe that this is a bug, since the API docs at
http://jinja.pocoo.org/docs/templates/#whitespace-control
explicitly state that "whitespace is not further modified".
You are correct in stating that the documentation does not match what is
happening in Jinja2. However at the same time that behavior is what
many people are currently expecting Jinja2 to do in testing conditions.
For most applications it does not matter either wait, it mostly affects
applications that generate HTML for output that might end up in console
sessions. If you look at code that currently uses Jinja2 you will
notice that these applications are appending an additional trailing
newline in order to force the final newline.
The reason why it was decided that way is that it does not matter either
way for most web applications and that most console applications are
using the print statement for output which appends an trailing newline.
However I would consider a flag that switches that behavior. The
following modes would make sense:
1. current behavior. Strip trailing newline
2. force final newline
3. use newline as specified in the source template.
Dropping normalization of newlines altogether however is a bad idea in
my mind as it causes a lot of troubles when using templates created by
designers on a windows system on OS X/Linux or the other way round.
That was the main motivation for the current behavior.
Regards,
Armin
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.