Jonathan French wrote: > Let me make sure I've got this right --- The situation being discussed is > not where whitespace is insignificant and can be stripped, but where > whitespace is important and you want to control the exact amount of it, > e.g. plain text emails. In this case, just using stripwhitespace is not > enough. Right?
Yes, that is the main problem. Django templates are useful (and used) for all sorts of text-based formats. For some of these, an exact control over whitespace is needed throughout the entire file (eg. text/plain), while for others, control is needed in some sensitive places (eg. element attributes in html and xml, which according to standars are not allowed to contain literal newlines.) The only option currently available to control whitespace is *not to use any* for the template syntax itself, in effect writing long one- liners. The admin site contains several examples of such: <div class="inline-related{% if forloop.last %} empty-form last- related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if not forloop.last %}{{ forloop.counter0 }}{% else %}empty{% endif %}"> Yes, in this case whitespace could be added between the class="" and id="" attributes, but the main issue remains there. Multiline comments {# #} and/or generic multiline tags would offer a more workable alternative than the present situation, allowing for syntax-only whitespace in templates. But they admittedly suffer from some serious ugliness and "denaturation" of Django templates. After reading all the above, I can see the arguments against this: <div class="inline-related{# #}{% if forloop.last %}{# #} empty-form last-related{# #}{% endif %}{# #}" id="{{ ... or even this: <div class="inline-related{% if forloop.last %} empty-form last-related{% endif %}" id="{{ ... Ugh!! This *will* be abused the instant it gets pushed, even if it's done on good intentions, such as allowing for multiline {% trans %}, in effect taking the beauty and readability out of the template language. But the main issue is still there, with its huge one-liners and other, even less readable workarounds. I think a new idea is needed, something more fine-grained than stripwhitespace and less denaturating than multiline comments. (Yes, I'm officially recognizing my original idea as flawed. Sorry for that. :-) Tobia -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.