mirror of
https://github.com/django-components/django-components.git
synced 2025-11-25 08:21:20 +00:00
Fix bug where template with multiple component_block tags could raise KeyError (#19)
Co-authored-by: rbeard0330 <@dul2k3BKW6m>
This commit is contained in:
parent
ed3f3125da
commit
979dc82eda
3 changed files with 55 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ class Component(with_metaclass(MediaDefiningClass)):
|
|||
return NodeList(node for node in template.template.nodelist if is_slot_node(node))
|
||||
|
||||
def render(self, context, slots_filled=None):
|
||||
slots_filled = slots_filled or []
|
||||
slots_filled = slots_filled or {}
|
||||
template = get_template(self.template(context))
|
||||
slots_in_template = self.slots_in_template(template)
|
||||
|
||||
|
|
|
|||
|
|
@ -148,11 +148,7 @@ class ComponentNode(Node):
|
|||
|
||||
with context.update(extra_context):
|
||||
self.slots.render(context)
|
||||
if COMPONENT_CONTEXT_KEY in context.render_context:
|
||||
slots_filled = context.render_context[COMPONENT_CONTEXT_KEY][self.component]
|
||||
else:
|
||||
slots_filled = []
|
||||
|
||||
slots_filled = context.render_context.get(COMPONENT_CONTEXT_KEY, {}).get(self.component, {})
|
||||
return self.component.render(context, slots_filled=slots_filled)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue