Repository navigation
Improved slot handling - #56
Conversation
Add tests and fix bug with traversal of nodelists
…ing of nodelists to limit cost of copies
|
I just pushed a couple additional commits. These address two issues:
|
|
THIS IS FANTASTIC!!! :D Thank you so much for this. Give me a couple of days to go through the changes you made. You made my day! :) |
EmilStenstrom
left a comment
There was a problem hiding this comment.
Now I've finally looked through it! I added some questions and minor things, but overall this looks great! Mind having a look so we can get this merged? :)
| """Retrieve the requested template and add a link to this component to each SlotNode in the template.""" | ||
|
|
||
| source_template = get_template(template_name) | ||
| component_template = copy(source_template) |
There was a problem hiding this comment.
Is this really needed? Removing it does not break any test, and all accesses below seem to be copying subparts of the template anyway.
There was a problem hiding this comment.
I think it is, but let me think about this and try to write a test to capture the problem if there is one.
There was a problem hiding this comment.
@rbeard0330 I don't want to rush, is this conversation still unresolved, or did your commit at the end resolve this? I don't know if you are waiting for me to check again or not :)
There was a problem hiding this comment.
All set. Just pushed some commits with the new test and some slight tweaking of this section.
Refactor component block parsing Add tests for parsing errors
|
Looks great! Thanks again for your hard work. I'll merge this right now and release version 0.13 🥳 🎊 🎆 |
Emil,
This should fix #34 and #37. The general approach is to allow
SlotNodes to render themselves, instead of removing them from the template and replacing them with the correct nodelist at the time the template is compiled. Now, the first time the component is rendered, it loads its template, searches through all the nodes in the template (including through descendants), and gives eachSlotNodea reference to itself (i.e., the parent component). Then, when it is time for theSlotNodeto render itself, it checks to see if it has a parent reference and, if it does, if the parent has an overriding nodelist for it to use. If an override exists, it renders that, otherwise it renders its default nodelist.I think it should be possible to extend this approach to handle #33 (slot.super()) as well, but I haven't fully thought that through yet.
As always, let me know of comments/questions/suggestions.
Best,
Robert