feat: on_render (#1231)

* 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
This commit is contained in:
Juro Oravec 2025-06-04 19:30:03 +02:00 committed by GitHub
parent 46e524e37d
commit eceebb9696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 1793 additions and 417 deletions

View file

@ -91,6 +91,10 @@
options:
show_if_no_docstring: true
::: django_components.OnRenderGenerator
options:
show_if_no_docstring: true
::: django_components.ProvideNode
options:
show_if_no_docstring: true

View file

@ -126,7 +126,8 @@ 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
`result` | `str` | The rendered component
`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:

View file

@ -20,7 +20,7 @@ Import as
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1022" target="_blank">See source code</a>
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1010" target="_blank">See source code</a>
@ -43,7 +43,7 @@ If you insert this tag multiple times, ALL CSS links will be duplicately inserte
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1044" target="_blank">See source code</a>
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1032" target="_blank">See source code</a>
@ -67,7 +67,7 @@ If you insert this tag multiple times, ALL JS scripts will be duplicately insert
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L3350" target="_blank">See source code</a>
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L3685" target="_blank">See source code</a>

View file

@ -3,8 +3,7 @@
# Template variables
Here is a list of all variables that are automatically available from inside the component's
template and in [`on_render_before` / `on_render_after`](../concepts/advanced/hooks.md#available-hooks)
hooks.
template:
::: django_components.component.ComponentVars.args