v0.142.0 (2025-10-05)ยค
__
Featยค
-
New built-in component
ErrorFallback
Use
ErrorFallback
to catch errors and display a fallback content instead.This is similar to React's
ErrorBoundary
component.Either pass the fallback as a kwarg:
{% component "error_fallback" fallback="Oops, something went wrong" %} {% component "table" / %} {% endcomponent %}
Or use the full
fallback
slot: -
Wrap the template rendering in
Component.on_render()
in a lambda function.When you wrap the rendering call in a lambda function, and the rendering fails, the error will be yielded back in the
(None, Exception)
tuple.Before:
class MyTable(Component): def on_render(self, context, template): try: intermediate = template.render(context) html, error = yield intermediate except Exception as e: html, error = None, e
After:
-
Multiple yields in
Component.on_render()
- You can now yield multiple times within the sameon_render
method for complex rendering scenarios.class MyTable(Component): def on_render(self, context, template): # First yield with context.push({"mode": "header"}): header_html, header_error = yield lambda: template.render(context) # Second yield with context.push({"mode": "body"}): body_html, body_error = yield lambda: template.render(context) # Third yield footer_html, footer_error = yield "Footer content" # Process all results if header_error or body_error or footer_error: return "Error occurred during rendering" return f"{header_html}\n{body_html}\n{footer_html}"
Each yield operation is independent and returns its own
(html, error)
tuple, allowing you to handle each rendering result separately.
Fixยค
-
Improve formatting when an exception is raised while rendering components. Error messages with newlines should now be properly formatted.
-
Add missing exports for
OnComponentRenderedContext
,OnSlotRenderedContext
,OnTemplateCompiledContext
,OnTemplateLoadedContext
.
Refactorยค
-
Changes to how
get_component_url()
handles query parameters:True
values are now converted to boolean flags (e.g.?enabled
instead of?enabled=True
).False
andNone
values are now filtered out.
Docsยค
- New people page to celebrate the contributors and authors!