Opened 16 years ago
Closed 12 years ago
#9256 closed Cleanup/optimization (wontfix)
Let the template parser remember it's root nodelist
Reported by: | Chris Beaven | Owned by: | Chris Beaven |
---|---|---|---|
Component: | Template system | Version: | |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This is useful if tags want to parse the templates root nodelist (built up to the current parsing point) for some reason.
As a specific example, I've got a {% repeatblock %}
tag (which duplicates the nodelist of an existing block) which needs this functionality.
Attachments (1)
Change History (12)
by , 16 years ago
Attachment: | root_nodelist.diff added |
---|
comment:1 by , 16 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 16 years ago
Sure. The problem I was facing is that my tag needed to find a separate node (generated by previously parsed tokens).
Currently, the parser creates a root nodelist when starts parsing the tokens (nodelist = self.create_nodelist()
) but there is no way to access this nodelist because it is only a local variable.
By allowing this to be an instance variable it allows tags (which accept the parser instance as one of the arguments) to inspect - and modify if necessary - the nodelist created so far.
Specifically, my {% repeatblock %}
tag was taking on the suggestion of Malcolm regarding allowing a the contents of a block node to be used more than once in an old discussion (which, in certain cases, would still be useful)
comment:4 by , 15 years ago
Version: | 1.0 |
---|
I couldn't find my old tag, so I remade it and put it here for an example: http://github.com/SmileyChris/django-repeatblock
comment:5 by , 15 years ago
Unfortunately this falls apart if the block and repeatblock tag occur in the same block-level tag (eg autoescape). I'm not sure if there is an easy fix :/
comment:6 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:9 by , 12 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:10 by , 12 years ago
Actually if the reason behind such a change is just the repeatblock
tag, I believe it's quite unnecessary as there is a solution for this particular problem -- goo.gl/caOOu
comment:11 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
It's not the reason, that was just an example of the usefulness of such a pointer.
But it's not something I've heard any requests for, and since I opened it, I'll close it.
I don't quite understand what this does -- can you give me more details about why this is important?