-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: loader tags compatibility #468
fix: loader tags compatibility #468
Conversation
# 2. Go over all nodes in the "parent" template, via `node.get_parent` | ||
nodes = NodeList() | ||
nodes.extend(node.nodelist) | ||
template = node.get_parent(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve the parent Template referenced via {% extends %}
tag, we needed to pass it a Context. That's why much of the non-test changes is adding a context
argument to functions
This snippet is taken directly from `IncludeNode.render()`. Unfortunately the | ||
render logic doesn't separate out template loading logic from rendering, so we | ||
have to copy the method. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it says above, this function is a copy from Django's codebase
for more information, see https://pre-commit.ci
@@ -1062,7 +1079,7 @@ def test_non_unique_fill_names_is_error(self): | |||
Template( | |||
""" | |||
{% load component_tags %} | |||
{% component "broken_component" %} | |||
{% component "test" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was using a wrong component for testing duplicate fills. After I fixed it, it turned out there were a few issues with duplicate fill detection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with releasing this, even though I don't understand it fully.
What would you say is the intuition on how block and slot works together? That the outermost tag executes first?
I'll write the behavior out, since it also took me some time to wrap my head around it:
|
I've included the explainer in docs/slots_and_blocks.md |
I just wanted to say that this is great work again. Thank you! |
Added tests to explore behavior of components with "loader tags" (
extends
,include
,block
). Tested out all combinations I could think of:include
extends
block
slot
Surprisingly, it all mostly worked as expected 😄, and I had to update only the traversal logic, so it could extract nodes from
extends
/include
tags.Closes #134