On Sat, 2008-11-29 at 17:37 -0800, stevedegrace wrote:
> I have a weird problem. (I'm using Django 1.0.2, Python version 2.5.2
> on Ubuntu 8.10). Say I have a template like this:
> 
> """
> {% sometag %}
> Some stuff
> {% someothertag %}
> Some more stuff
> {% yetanothertag %}
> Last stuff
> {% endsometag %}
> """
> My template tag function looks something like this:
> 
> @register.tag(name="sometag")
> def do_sometag(parser, token):
>     nodelist1 = parser.parse(('someothertag',' yetanothertag',
> 'endsometag'))
>     parser.delete_first_token()
>     nodelist2 = parser.parse(('someothertag',' yetanothertag',
> 'endsometag'))
>     parser.delete_first_token()
>     # ... do some stuff ... no point returning a node, not going to
> get that far...

Looks like using delete_first_token() in the middle of a parsing
operation like this isn't vaild. It changes the list of tokens in place,
which might be messing up the parsing state. In the documentation (and
all the uses of delete_first_token in the Django template tags), it's
only used as the very last thing before passing the remainder to a Node
object.

The if...else block tag would be a good pattern to model code on.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" 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/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to