Slot/fill names must be strings change #270
-
I've just upgraded out Django project to use django-components 0.27.1 and there is a lot of breaking changes, most of which are related to the fact that I've used slots as I would blocks, e.g., {% component_block "menu" %}
{% fill items %}
<a href="#">Some item</a>
{% endslot items %}
{% endcomponent_block %} The same is true of when I define a component with slots, instead of fills. I liked doing this since when content gets long and there are multiple slots, it acts as a good way to document where they start and end without comments. It's the same as when you use block/endblock. What was the reason for changing this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi there, sorry to hear this change is causing you problems! What you're observing is indeed the result of a conscious decision to treat the first argument to It was something that came up in the course of PR #221, where you'll find a record of the decision making process. I'll try to give a summary here.
My personal thoughts on this are that I prefer the previous approach of treating names as literal identifiers. I don't see myself using dynamically specified components or fill tags any time soon, and my own style is to use Regarding your second point, about repeating the slot/fill name in the |
Beta Was this translation helpful? Give feedback.
Hi there, sorry to hear this change is causing you problems!
What you're observing is indeed the result of a conscious decision to treat the first argument to
slot
andfill
tags as a variable rather than as a literal identifier.It was something that came up in the course of PR #221, where you'll find a record of the decision making process. I'll try to give a summary here.
fill
tags, the 'slots are like blocks' analogy broke down. Slots no longer override slots on some parent template. Instead, the new fill tags co-ordinate with slot tags in a way that no longer resembles the inheritance-based approach ofblock
tags. Mimicing theblock
way of parsing tag argumen…