Skip to content

Releases: django-components/django-components

0.126

29 Jan 13:38
3d187d7
Compare
Choose a tag to compare

⚠️ Attention ⚠️ - We recently migrated from EmilStenstrom/django-components to django-components/django-components.

What's Changed

Refactor

  • Improved render time ~5x by replacing BeautifulSoup4 with own Rust HTML parser implementation.
  • The heuristic for inserting JS and CSS dependenies into the default place has changed.
    • JS is still inserted at the end of the <body>, and CSS at the end of <head>.
    • However, we find end of <body> by searching for last occurrence of </body>
    • And for the end of <head> we search for the first occurrence of </head>

Full Changelog: 0.125...0.126

0.125

22 Jan 15:11
914576e
Compare
Choose a tag to compare

What's Changed

⚠️ Attention ⚠️ - We migrated from EmilStenstrom/django-components to django-components/django-components.

Repo name and documentation URL changed. Package name remains the same.

If you see any broken links or other issues, please report them in #922.

Feat

  • @template_tag and BaseNode - A decorator and a class that allow you to define
    custom template tags that will behave similarly to django-components' own template tags.

    Read more on Template tags.

    Template tags defined with @template_tag and BaseNode will have the following features:

    • Accepting args, kwargs, and flags.

    • Allowing literal lists and dicts as inputs as:

      key=[1, 2, 3] or key={"a": 1, "b": 2}

    • Using template tags tag inputs as:

      {% my_tag key="{% lorem 3 w %}" / %}

    • Supporting the flat dictionary definition:

      attr:key=value

    • Spreading args and kwargs with ...:

      {% my_tag ...args ...kwargs / %}

    • Being able to call the template tag as:

      {% my_tag %} ... {% endmy_tag %} or {% my_tag / %}

Refactor

  • Refactored template tag input validation. When you now call template tags like
    {% slot %}, {% fill %}, {% html_attrs %}, and others, their inputs are now
    validated the same way as Python function inputs are.

    So, for example

    {% slot "my_slot" name="content" / %}

    will raise an error, because the positional argument name is given twice.

    NOTE: Special kwargs whose keys are not valid Python variable names are not affected by this change.
    So when you define:

    {% component data-id=123 / %}

    The data-id will still be accepted as a valid kwarg, assuming that your get_context_data()
    accepts **kwargs:

    def get_context_data(self, **kwargs):
        return {
            "data_id": kwargs["data-id"],
        }

Full Changelog: 0.124...0.125

0.124

07 Jan 22:05
3bbd432
Compare
Choose a tag to compare

⚠️ Attention ⚠️ If you rely on Django loaders to preprocess the templates (e.g. using Pug or similar), see #901.

What's Changed

Feat

  • Instead of inlining the JS and CSS under Component.js and Component.css, you can move
    them to their own files, and link the JS/CSS files with Component.js_file and Component.css_file.

    Even when you specify the JS/CSS with Component.js_file or Component.css_file, then you can still
    access the content under Component.js or Component.css - behind the scenes, the content of the JS/CSS files
    will be set to Component.js / Component.css upon first access.

    The same applies to Component.template_file, which will populate Component.template upon first access.

    With this change, the role of Component.js/css and the JS/CSS in Component.Media has changed:

    • The JS/CSS defined in Component.js/css or Component.js/css_file is the "main" JS/CSS
    • The JS/CSS defined in Component.Media.js/css are secondary or additional

    See the updated "Getting Started" tutorial

Refactor

  • The canonical way to define a template file was changed from template_name to template_file, to align with the rest of the API.

    template_name remains for backwards compatibility. When you get / set template_name,
    internally this is proxied to template_file.

  • The undocumented Component.component_id was removed. Instead, use Component.id. Changes:

    • While component_id was unique every time you instantiated Component, the new id is unique
      every time you render the component (e.g. with Component.render())
    • The new id is available only during render, so e.g. from within get_context_data()
  • Component's HTML / CSS / JS are now resolved and loaded lazily. That is, if you specify template_name/template_file,
    js_file, css_file, or Media.js/css, the file paths will be resolved only once you:

    1. Try to access component's HTML / CSS / JS, or
    2. Render the component.

    Read more on Accessing component's HTML / JS / CSS.

  • Component inheritance:

    • When you subclass a component, the JS and CSS defined on parent's Media class is now inherited by the child component.
    • You can disable or customize Media inheritance by setting extend attribute on the Component.Media nested class. This work similarly to Django's Media.extend.
    • When child component defines either template or template_file, both of parent's template and template_file are ignored. The same applies to js_file and css_file.
  • Autodiscovery now ignores files and directories that start with an underscore (_), except __init__.py

  • The Signals emitted by or during the use of django-components are now documented, together the template_rendered signal.

Full Changelog: 0.123...0.124

0.123

23 Dec 12:11
c76f819
Compare
Choose a tag to compare

What's Changed

Fix

  • Fix edge cases around rendering components whose templates used the {% extends %} template tag (#859) (thanks @ldurey)

Full Changelog: 0.122...0.123

0.122

19 Dec 09:28
6bb73bd
Compare
Choose a tag to compare

What's Changed

Feat

Full Changelog: 0.121...0.122

0.121

17 Dec 19:38
6681fc0
Compare
Choose a tag to compare

What's Changed

Fix

  • Fix the use of Django template filters (|lower:"etc") with component inputs #855.

Docs

  • docs: fix links in README and "overview" section, add tutorial in #842

Full Changelog: 0.120...0.121

0.120

15 Dec 06:47
6813c9d
Compare
Choose a tag to compare

⚠️ Attention ⚠️ - Please update to v0.121 to fix bugs introduced in v0.119.

What's Changed

Fix

  • Fix the use of translation strings _("bla") as inputs to components #849.

Full Changelog: 0.119...0.120

0.119

13 Dec 09:09
aaeba99
Compare
Choose a tag to compare

⚠️ Attention ⚠️ - This release introduced bugs #849, #855. Please update to v0.121.

What's Changed

Fix

  • Fix compatibility with custom subclasses of Django's Template that need to access
    origin or other initialization arguments. (#828)

  • Fix compatibility with django-debug-toolbar-template-profiler - Monkeypatching of Django's Template now happens up-front at AppConfig.ready() (#825)

Refactor

  • Internal parsing of template tags tag was updated. No API change. (#827)

Full Changelog: 0.118...0.119

0.118

10 Dec 12:47
a565969
Compare
Choose a tag to compare

What's Changed

Feat

  • Add support for context_processors and RenderContext inside component templates (by @lhole in #817)

    Component.render() and Component.render_to_response() now accept an extra kwarg request.

    def my_view(request)
        return MyTable.render_to_response(
            request=request
        )
    • When you pass in request, the component will use RenderContext instead of Context.
      Thus the context processors will be applied to the context.

    • NOTE: When you pass in both request and context to Component.render(), and context is already an instance of Context, the request kwarg will be ignored.

Refactor

  • Fix sampleproject component-relative (#833)

Docs

  • Fix link to license in README (#834)

New Contributors

Full Changelog: 0.117...0.118

0.117

08 Dec 08:04
2f14e8e
Compare
Choose a tag to compare

What's Changed

Fix

  • The HTML parser no longer erronously inserts <html><head><body> on some occasions, and
    no longer tries to close unclosed HTML tags (#793)

Refactor

Full Changelog: 0.116...0.117