* needs_better_patch: 0 => 1
* easy: => 0
Comment:
0001-Commiting-whitespace-patch-from-django-ticket-2594.2.patch fails to
apply cleanly on to trunk
--
Ticket URL: <http://code.djangoproject.com/ticket/2594#comment:35>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by tobia):
I just started a thread about an alternative solution to this problem.
Newline stripping in templates: the dnl way
http://groups.google.com/group/django-
developers/browse_thread/thread/8d6b6a3aae82ee03
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:37>
* cc: kmike84@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:38>
* cc: andrep (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:39>
* cc: Twidi (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:40>
Comment (by anonymous):
Please someone from django core sacrifice a day, and test and ad this to
1.4.x. Thanks a lot!
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:41>
* cc: Florian.Sening@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:42>
* cc: waldir (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:43>
* cc: ldiqual@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:44>
* cc: python@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:45>
Comment (by leonov):
I've spent the morning updating the patch against the latest development
version.
It was fairly straightforward, except for the `Lexer.create_token()`
method, which took some time. It was already fairly hairy in 1.4, and the
addition of the `verbatim` tag in 1.5-dev had made it even more so. I've
added comments to make it easier for the next person to unravel the logic.
All tests pass, pre- and post-patch, and the results of Gary Wilson's
benchmark remain good.
{{{
python -m timeit -n500 -s 'from bm import my_render' 'my_render()'
Without patch:
500 loops, best of 3: 1.96 msec per loop
500 loops, best of 3: 1.95 msec per loop
500 loops, best of 3: 1.96 msec per loop
With patch, TEMPLATE_STRIP_LEADING_WHITESPACE = True:
500 loops, best of 3: 1.96 msec per loop
500 loops, best of 3: 1.96 msec per loop
500 loops, best of 3: 1.97 msec per loop
With patch, TEMPLATE_STRIP_LEADING_WHITESPACE = False:
500 loops, best of 3: 1.99 msec per loop
500 loops, best of 3: 2 msec per loop
500 loops, best of 3: 2.01 msec per loop
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:46>
* cc: ua_django_bugzilla@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:47>
* cc: s.shanabrook@… (added)
Comment:
What needs to be done to get this merged still?
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:48>
Comment (by mrmachine):
You could try reading through the ticket and django-developers group
history so that you're familiar with all the options and opinions that
have been presented. Then outline a proposal on the django-developers
group to move the ticket forward by choosing a preferred option (probably
the one which had the most support), summarise why it has been chosen over
any others, update any patches so that they apply cleanly and ask for a
code review and any final objections that would delay this being
committed.
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:49>
Comment (by anonymous):
Why not implement the {%- tag -%} support in Jinja2, and let people choose
themselves?
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:50>
* cc: chipx86@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:51>
* cc: tomasbabej@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:52>
Comment (by FunkyBob):
There's no way I'd want to have _only_ a global flag to enable this
behaviour. Certainly, there are cases where I'd rather avoid leading
spaces and blank lines, but equally there are cases where it's important.
Not all the world is HTML. Django templates are frequently used for
content types where the leading whitespace may be important, in the same
projects where it's used for HTML, where it's less important.
Typically to avoid these problems I've started using constructs like:
{{{
<h1>The title</h1>
<ul>{% for item in somelist %}
<li>{{ item }}</li>{% endfor %}
</ul>
}}}
Perhaps not as obvious with the template tags, but clearer with the HTML.
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:53>
Comment (by Semmel):
Just wanted to note that this is exactly the problem I'm facing. Not
everything is HTML and sometimes whitespace matters. The templates for
these cases are very hard to read. :/
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:54>
* cc: trbs@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:55>
* status: new => closed
* resolution: => wontfix
Comment:
As far as I know, the consensus among the core team is that:
- the Django template language is good enough for generating HTML, which
isn't sensitive to whitespace;
- the long term plan is to replace it with a better engine (most likely
Jinja), not to keep working on it;
- if you have more specialized needs (want to generate RTF?) just use
another template engine, there are several to choose from.
Hence, closing wontfix. Thanks everyone who tried contributing to this
ticket, and sorry it didn't happen.
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:56>
Comment (by mrmachine):
Is there an open ticket for tracking the progress of integrating Django's
newly blessed template engine (Jinja)? Or any indication on how "long
term" that plan is? Was there a google groups discussion about this long
term plan?
I did a quick search and couldn't find either. That being the case, it
seems that if no new improvements will be made to Django's template engine
because it might be replaced in the next 5-10 years (seems like a big
job), that's simply leaving everyone who finds the current engine lacking
in any way, stuck in limbo indefinitely.
Is the existing template engine in permanent feature freeze now? Only bug
fixes allowed?
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:57>
Comment (by aaugustin):
Let me restate this with more plainly: we're not interested in this
feature and we don't provide an alternative.
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:58>
Comment (by anonymous):
I think that what @aaugustin is trying to say is:
Google.com/search?q=how+do+i+use+jinja2+with+django
There, another bug fixed; right?
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:59>
Comment (by amfarrell):
To achieve this from jinja2, pass both trim_blocks=True and
lstrip_blocks=True when you instantiate either your Environment or
Template.
see: http://jinja.pocoo.org/docs/dev/templates/#whitespace-control
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:60>
* cc: adehnert (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/2594#comment:61>