In Rails, template tags can have an extra hyphen at the end to denote
the fact that they should consume the newline right after the tag. So:

{% some_tag %}

Would look like this:

{% some_tag -%}

Isn't it possible to just add this functionality by making the newline
that comes right after the tag part of the regex of the tag?

Something like this:

------------------------
# template syntax constants
[...]
BLOCK_TAG_END_NO_NEWLINE = '-%}\n'
[...]
tag_re = re.compile('(%s.*?(%s|%s)|%s.*?%s)' % \

(re.escape(BLOCK_TAG_START),
                                              re.escape(BLOCK_TAG_END),

re.escape(BLOCK_TAG_END_NO_NEWLINE),

re.escape(VARIABLE_TAG_START),

re.escape(VARIABLE_TAG_END)))
------------------------

Just one more small change to Lexer.create_token and we are all set up.
This way the newline will be matched with the tag and consumed, and
therefore it will just disappear. No big performance hit sustained.

(Note that I did not test any of this)


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to