#15387: Parameter parse_until doesn't compare to tag name.
--------------------------------------------+-------------------------------
 Reporter:  klein4                          |          Owner:  nobody    
   Status:  new                             |      Milestone:            
Component:  Template system                 |        Version:  1.2       
 Keywords:  template, template tag, parser  |   Triage Stage:  Unreviewed
Has patch:  1                               |  
--------------------------------------------+-------------------------------
 django.template.Parser.parse() takes an argument `parse_until`, which the
 docs say is a tuple of tag names which indicate that parsing should halt.
 However, when Parser.parse() finds a new token of token_type=TOKEN_BLOCK,
 it tests `token.contents in parse_until` rather than
 `token.contents.split_token()[0] in parse_until`. The latter more closely
 matches the documented functionality.

 This distinction is relevant when tokens after the initial tag contain
 arguments.

 To see why this is useful, consider a custom block tag `random` which
 randomly chooses a nodelist according to its weight. It might be invoked
 like this:

 {% random "2" %}
 This node has a 2/7 chance of being chosen.
 {% or "2" %}
 This node has a 2/7 chance of being chosen.
 {% or "3" %}
 This node has a 3/7 chance of being chosen.
 {% endrandom %}

 As it currently stands, it is impossible to give non-initial tokens
 arguments as in this example. This may be considered a non-trivial patch,
 but it seems to align with the documented functionality of the
 `parse_until` parameter.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15387>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to