mirror of
https://github.com/django-components/django-components.git
synced 2025-08-10 01:08:00 +00:00

* feat: on_render * docs: fix typos * refactor: fix linter errors * refactor: make `error` in on_render_after optional to fix benchmarks * refactor: benchmark attempt 2 * refactor: fix linter errors * refactor: fix formatting
251 lines
8.4 KiB
Markdown
251 lines
8.4 KiB
Markdown
<!-- Autogenerated by reference.py -->
|
|
|
|
# Extension hooks
|
|
|
|
Overview of all the extension hooks available in Django Components.
|
|
|
|
Read more on [Extensions](../../concepts/advanced/extensions).
|
|
|
|
|
|
## Hooks
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_class_created
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The created Component class
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_class_deleted
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The to-be-deleted Component class
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_data
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component` | [`Component`](../api#django_components.Component) | The Component instance that is being rendered
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The Component class
|
|
`component_id` | `str` | The unique identifier for this component instance
|
|
`context_data` | `Dict` | Deprecated. Use `template_data` instead. Will be removed in v1.0.
|
|
`css_data` | `Dict` | Dictionary of CSS data from `Component.get_css_data()`
|
|
`js_data` | `Dict` | Dictionary of JavaScript data from `Component.get_js_data()`
|
|
`template_data` | `Dict` | Dictionary of template data from `Component.get_template_data()`
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_input
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`args` | `List` | List of positional arguments passed to the component
|
|
`component` | [`Component`](../api#django_components.Component) | The Component instance that received the input and is being rendered
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The Component class
|
|
`component_id` | `str` | The unique identifier for this component instance
|
|
`context` | [`Context`](https://docs.djangoproject.com/en/5.2/ref/templates/api/#django.template.Context) | The Django template Context object
|
|
`kwargs` | `Dict` | Dictionary of keyword arguments passed to the component
|
|
`slots` | `Dict[str, Slot]` | Dictionary of slot definitions
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_registered
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The registered Component class
|
|
`name` | `str` | The name the component was registered under
|
|
`registry` | [`ComponentRegistry`](../api#django_components.ComponentRegistry) | The registry the component was registered to
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_rendered
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component` | [`Component`](../api#django_components.Component) | The Component instance that is being rendered
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The Component class
|
|
`component_id` | `str` | The unique identifier for this component instance
|
|
`error` | `Optional[Exception]` | The error that occurred during rendering, or `None` if rendering was successful
|
|
`result` | `Optional[str]` | The rendered component, or `None` if rendering failed
|
|
|
|
::: django_components.extension.ComponentExtension.on_component_unregistered
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The unregistered Component class
|
|
`name` | `str` | The name the component was registered under
|
|
`registry` | [`ComponentRegistry`](../api#django_components.ComponentRegistry) | The registry the component was unregistered from
|
|
|
|
::: django_components.extension.ComponentExtension.on_registry_created
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`registry` | [`ComponentRegistry`](../api#django_components.ComponentRegistry) | The created ComponentRegistry instance
|
|
|
|
::: django_components.extension.ComponentExtension.on_registry_deleted
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`registry` | [`ComponentRegistry`](../api#django_components.ComponentRegistry) | The to-be-deleted ComponentRegistry instance
|
|
|
|
::: django_components.extension.ComponentExtension.on_slot_rendered
|
|
options:
|
|
heading_level: 3
|
|
show_root_heading: true
|
|
show_signature: true
|
|
separate_signature: true
|
|
show_symbol_type_heading: false
|
|
show_symbol_type_toc: false
|
|
show_if_no_docstring: true
|
|
show_labels: false
|
|
|
|
**Available data:**
|
|
|
|
name | type | description
|
|
--|--|--
|
|
`component` | [`Component`](../api#django_components.Component) | The Component instance that contains the `{% slot %}` tag
|
|
`component_cls` | [`Type[Component]`](../api#django_components.Component) | The Component class that contains the `{% slot %}` tag
|
|
`component_id` | `str` | The unique identifier for this component instance
|
|
`result` | `SlotResult` | The rendered result of the slot
|
|
`slot` | `Slot` | The Slot instance that was rendered
|
|
`slot_is_default` | `bool` | Whether the slot is default
|
|
`slot_is_required` | `bool` | Whether the slot is required
|
|
`slot_name` | `str` | The name of the `{% slot %}` tag
|
|
`slot_node` | `SlotNode` | The node instance of the `{% slot %}` tag
|
|
|
|
## Objects
|
|
|
|
::: django_components.extension.OnComponentClassCreatedContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnComponentClassDeletedContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnComponentDataContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnComponentInputContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnComponentRegisteredContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnComponentUnregisteredContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnRegistryCreatedContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|
|
::: django_components.extension.OnRegistryDeletedContext
|
|
options:
|
|
heading_level: 3
|
|
show_if_no_docstring: true
|
|
|