Slots in code. #1091
-
Hi I'm very stuck here. Am trying to figure out how I can access the slots passed into my components in code. Ideally there would be some way to access what's been passed into slots inside the For context, I've got a component Thanks heaps. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Hey @HenkWillcock, you can access them from within the E.g. in the example below is how you would render a slot with the same context that's used for rendering the slots: class MyTable(Component):
def get_context_data(self, *args, **kwargs):
footer_slot = self.input.slots["footer"]
footer_content = footer_slot(self.outer_context, None, None) Any suggestions on where to put this info to make it more visible? PS: Note to self, currently the functions for rendering the slots from within the Python are a bit crude - they accept the inputs that we need to pass internally. But from user perspective, the function interface |
Beta Was this translation helpful? Give feedback.
Hey @HenkWillcock, you can access them from within the
get_context_data()
viaself.input.slots
.E.g. in the example below is how you would render a slot with the same context that's used for rendering the slots:
Any suggestions on where to put this info to make it more visible?
PS: Note to self, currently the functions for rendering the slots from within the Python are a bit crude - they accept the inputs that we need to pass internally.
But from user perspective, the function interface
slot(Contex…