diff --git a/django_components/component.py b/django_components/component.py index aeb51c4d..f61d978e 100644 --- a/django_components/component.py +++ b/django_components/component.py @@ -1,4 +1,3 @@ -import copy from typing import ( TYPE_CHECKING, ClassVar, @@ -126,12 +125,13 @@ class Component(metaclass=SimplifiedInterfaceMediaDefiningClass): return self._outer_context or {} def get_updated_fill_stacks(self, context): - current_fill_stacks = context.get(FILLED_SLOTS_CONTEXT_KEY, None) - updated_fill_stacks = ( - copy.deepcopy(current_fill_stacks) - if current_fill_stacks is not None - else {} + current_fill_stacks: Optional[Dict[str, List[FillNode]]] = context.get( + FILLED_SLOTS_CONTEXT_KEY, None ) + updated_fill_stacks = {} + if current_fill_stacks: + for name, fill_nodes in current_fill_stacks.items(): + updated_fill_stacks[name] = list(fill_nodes) for name, fill in self.instance_fills.items(): if name in updated_fill_stacks: updated_fill_stacks[name].append(fill) diff --git a/sampleproject/components/calendar/calendar.html b/sampleproject/components/calendar/calendar.html index c1d4dbf2..5aa25273 100644 --- a/sampleproject/components/calendar/calendar.html +++ b/sampleproject/components/calendar/calendar.html @@ -1 +1,13 @@ -
Today's date is {{ date }}
\ No newline at end of file +
+
Today's date is {{ date }}
+
Your to-dos:
+ +
\ No newline at end of file diff --git a/sampleproject/components/todo/todo.html b/sampleproject/components/todo/todo.html new file mode 100644 index 00000000..2dc27b2c --- /dev/null +++ b/sampleproject/components/todo/todo.html @@ -0,0 +1,4 @@ +
+ {% slot "todo_text" %} + {% endslot %} +
\ No newline at end of file diff --git a/sampleproject/components/todo/todo.py b/sampleproject/components/todo/todo.py new file mode 100644 index 00000000..5f103964 --- /dev/null +++ b/sampleproject/components/todo/todo.py @@ -0,0 +1,9 @@ +from django_components import component + + +@component.register("todo") +class Calendar(component.Component): + # Note that Django will look for templates inside `[your apps]/components` dir and + # `[project root]/components` dir. To customize which template to use based on context + # you can override def get_template_name() instead of specifying the below variable. + template_name = "todo/todo.html"