Skip to content

0.141.0

Latest
Compare
Choose a tag to compare
@JuroOravec JuroOravec released this 10 Jun 09:14
· 11 commits to master since this release
06c89cf

What's Changed

Feat

  • New extension hooks on_template_loaded, on_js_loaded, on_css_loaded, and on_template_compiled

    The first 3 hooks are called when Component's template / JS / CSS is loaded as a string.

    The on_template_compiled hook is called when Component's template is compiled to a Template.

    The on_xx_loaded hooks can modify the content by returning the new value.

    class MyExtension(ComponentExtension):
        def on_template_loaded(self, ctx: OnTemplateLoadedContext) -> Optional[str]:
            return ctx.content + "<!-- Hello! -->"
    
        def on_js_loaded(self, ctx: OnJsLoadedContext) -> Optional[str]:
            return ctx.content + "// Hello!"
    
        def on_css_loaded(self, ctx: OnCssLoadedContext) -> Optional[str]:
            return ctx.content + "/* Hello! */"

    See all Extension hooks.

Fix

  • Subclassing - Previously, if a parent component defined Component.template or Component.template_file, it's subclass would use the same Template instance.

    This could lead to unexpected behavior, where a change to the template of the subclass would also change the template of the parent class.

    Now, each subclass has it's own Template instance, and changes to the template of the subclass do not affect the template of the parent class.

  • Fix Django failing to restart due to "TypeError: 'Dynamic' object is not iterable" (#1232)

  • Fix bug when error formatting failed when error value was not a string.

Refactor

  • components ext run CLI command now allows to call only those extensions that actually have subcommands.

Full Changelog: 0.140.1...0.141.0