You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Slot is not executed in conditional {% if %} block #37
I wonder if this is related to #34: the current implementation of slots as a simple list doesn't work when the slots themselves are executed conditionally.
I wonder if this is related to #34: the current implementation of slots as a simple list doesn't work when the slots themselves are executed conditionally.
I think this is right. The current implementation looks at the components nodelist, identifies any slot nodes in that nodelist, then replaces them with either the provided content or the default content. In both of these issues, the problem is that there is a slot nested within some other node (either an IfNode or another slot). If that happens, then the SlotNode isn't removed when the template is compiled, and it renders itself using its default content.
You could potentially fix this by making the search for slots recursive. In conjunction with that, I think you'd also want to modify the slot's own nodelist rather than replacing it like we do currently, to minimize the chance that we violate some other node's expectations.
Activity
danjac commentedon Feb 27, 2021
I wonder if this is related to #34: the current implementation of slots as a simple list doesn't work when the slots themselves are executed conditionally.
EmilStenstrom commentedon Feb 27, 2021
Interesting, you are a great tester for this project! :) I think we should do whatever block is doing, makes sense.
jereze commentedon Mar 19, 2021
Hi,
I noticed the same behavior.
EmilStenstrom commentedon Mar 20, 2021
@jereze Would you mind helping to fix it? A PR that adds a test that shows the error would be a great start for instance.
rbeard0330 commentedon Mar 20, 2021
I think this is right. The current implementation looks at the components nodelist, identifies any slot nodes in that nodelist, then replaces them with either the provided content or the default content. In both of these issues, the problem is that there is a slot nested within some other node (either an
IfNodeor another slot). If that happens, then theSlotNodeisn't removed when the template is compiled, and it renders itself using its default content.You could potentially fix this by making the search for slots recursive. In conjunction with that, I think you'd also want to modify the slot's own nodelist rather than replacing it like we do currently, to minimize the chance that we violate some other node's expectations.
Improve slot handling to allow nested components, conditional slots, …
Improve slot handling to allow nested components, conditional slots, …