diff --git a/dev/concepts/fundamentals/components_in_python/index.html b/dev/concepts/fundamentals/components_in_python/index.html index 0969a60b..32717e98 100644 --- a/dev/concepts/fundamentals/components_in_python/index.html +++ b/dev/concepts/fundamentals/components_in_python/index.html @@ -31,7 +31,7 @@ slots: Dict[str, str | SafeString | SlotFunc] | None = None, escape_slots_content: bool = True ) -> str: -
args
- Positional args for the component. This is the same as calling the component as {% component "my_comp" arg1 arg2 ... %}
kwargs
- Keyword args for the component. This is the same as calling the component as {% component "my_comp" key1=val1 key2=val2 ... %}
slots
- Component slot fills. This is the same as pasing {% fill %}
tags to the component. Accepts a dictionary of { slot_name: slot_content }
where slot_content
can be a string or SlotFunc
.
escape_slots_content
- Whether the content from slots
should be escaped. True
by default to prevent XSS attacks. If you disable escaping, you should make sure that any content you pass to the slots is safe, especially if it comes from user input.
context
- A context (dictionary or Django's Context) within which the component is rendered. The keys on the context can be accessed from within the template.
SlotFunc
¤When rendering components with slots in render
or render_to_response
, you can pass either a string or a function.
The function has following signature:
args
- Positional args for the component. This is the same as calling the component as {% component "my_comp" arg1 arg2 ... %}
kwargs
- Keyword args for the component. This is the same as calling the component as {% component "my_comp" key1=val1 key2=val2 ... %}
slots
- Component slot fills. This is the same as pasing {% fill %}
tags to the component. Accepts a dictionary of { slot_name: slot_content }
where slot_content
can be a string or SlotFunc
.
escape_slots_content
- Whether the content from slots
should be escaped. True
by default to prevent XSS attacks. If you disable escaping, you should make sure that any content you pass to the slots is safe, especially if it comes from user input.
context
- A context (dictionary or Django's Context) within which the component is rendered. The keys on the context can be accessed from within the template.
NOTE: In "isolated" mode, context is NOT accessible, and data MUST be passed via component's args and kwargs.
request
- A Django request object. This is used to enable Django template context_processors
to run,
allowing for template tags like {% csrf_token %}
and variables like {{ debug }}
.
context
to a RequestContext. It does nothing if context
is already a Context
instance.SlotFunc
¤When rendering components with slots in render
or render_to_response
, you can pass either a string or a function.
The function has following signature:
def render_func(
context: Context,
data: Dict[str, Any],
slot_ref: SlotRef,
@@ -61,4 +61,4 @@
response = SimpleComponent.render_to_response()
assert isinstance(response, MyResponse)
-