Closed mattbha closed 3 weeks ago
I added the ability to add only to a component to isolate the components context from the parent (similar to what django implements for include: https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#include)
only
with a simple component:
simple.html
<a class="{{ class|default:"donttouch" }}">test</a>
this component, with parent context {"class":"herebedragons"} will render (as normal) <c-simple /> as <a class="herebedragons">test</a>
{"class":"herebedragons"}
<c-simple />
<a class="herebedragons">test</a>
whereas <c-simple only /> (with the same parent context {"class":"herebedragons"}) renders as <a class="donttouch">test</a>
<c-simple only />
<a class="donttouch">test</a>
I think the tests I added are sufficient but I'm not 100% sure.
if this is accepted we probably should also update the docs.
@mattbha Looks good, thanks - I will line up change to docs
I added the ability to add
only
to a component to isolate the components context from the parent (similar to what django implements for include: https://docs.djangoproject.com/en/5.1/ref/templates/builtins/#include)with a simple component:
simple.html
<a class="{{ class|default:"donttouch" }}">test</a>
this component, with parent context
{"class":"herebedragons"}
will render (as normal)<c-simple />
as<a class="herebedragons">test</a>
whereas
<c-simple only />
(with the same parent context{"class":"herebedragons"}
) renders as<a class="donttouch">test</a>
I think the tests I added are sufficient but I'm not 100% sure.