v0.142.0ยค
Featยค
-
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, eAfter:
-
Multiple yields in
Component.on_render()- You can now yield multiple times within the sameon_rendermethod 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:Truevalues are now converted to boolean flags (e.g.?enabledinstead of?enabled=True).FalseandNonevalues are now filtered out.