Skip to content

Releases: wrabit/django-cotton

2.6.0

18 Dec 15:51
978da0f

Choose a tag to compare

Support DTL-like Shorthand Dynamic Attributes Without : and Quotes

Cotton now supported supplying dynamic attributes without quotes and :. This aligns better with native DTL where you can pass template context vars or bool + None as quote-less values.

Previously:

<c-some-component 
  :required="True" 
  :age="3"
  :template-variable="my_var"
/>

Now we can optionally use the shorthand approach of:

<c-some-component 
  required=True
  age=3
  template-variable=my_var
/>

This is purely optional and the traditional approach is still fully supported and in fact still required for complex cases like string literal Dicts or Lists.

<c-some-component 
  :config="{'multiplier': 0.3, 'category': 'x'}"
  :items="['on', 'off']"
/>

The current version will remain fully supported and is still the required approach when dealing with more complex dynamic attributes like string literals with nested quotes and spaces.

  • chore: Add support for quoteless dynamic attributes (ala DTL) by @wrabit in #328

2.5.1

08 Dec 07:58
6e1209a

Choose a tag to compare

Improved support of nested tags containing quotes

New Contributors

Full Changelog: 2.5.0...2.5.1

2.5.0 - render_component()

20 Nov 22:21

Choose a tag to compare

render_component() helper for HTMX partials

Added a new render_component() helper function to enable rendering Cotton components from Django views, particularly useful for HTMX partial responses.

Usage:

  from django_cotton import render_component
  from django.http import HttpResponse

  def my_view(request):
      return HttpResponse(
          render_component(request, "notification",
              message="Action completed",
              type="success"
          )
      )

The function signature follows Django's render() convention: render_component(request, component_name, context).

Key features:

  • Request is always provided, ensuring context processors and other internals work correctly
  • Context given to the helper is provided as attributes to the component so all cotton behaviour works as normal
  • Works with nested components
  • Supports both dict and kwargs syntax

See the README for an example.

What's Changed

Full Changelog: 2.4.0...2.5.0

2.4.0 - Native tag support

14 Nov 17:11
989f82f

Choose a tag to compare

Add support for native {% cotton %} tags

Since cotton compiles down to native Django template tags, it's logical to document it as a perfectly good approach to using cotton, skipping html-like syntax that the compiler permits.

Syntax Equivalents

Feature HTML-like Syntax Native Template Syntax
Component <c-button>...</c-button> {% cotton button %}...{% endcotton %}
Self-closing <c-button /> {% cotton button / %}
Variables <c-vars title /> {% cotton:vars title %}
Named Slot <c-slot name="header">...</c-slot> {% cotton:slot header %}...{% endcotton:slot %}

Documentation changes

Docs now have a syntax switcher will all examples having a native tag equivalent:

image image

⚠️ This will not be a breaking change for the vast majority as the template tags were never documented, but if you dug into the code and actually started using them before now - this release changes the tag names that were previously being used internally.

Full Changelog: 2.3.1...2.4.0

2.3.1

11 Nov 23:02
2a6cb13

Choose a tag to compare

What's Changed

2.3.0

10 Nov 07:12
852d23c

Choose a tag to compare

Compiler update and lower level support for nested tags

This release moves some of the responsibility from cotton compiler and core component of managing complex attributes to the tokenizer stage so the parsing is handled more natively.

Summary of changes

This fixes:

Makes way for:

2.1.4 - Support Django 6.0

06 Nov 11:44
59507a9

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 2.1.3...2.1.4

2.1.3

30 Jun 17:34

Choose a tag to compare

What's Changed

  • Fixes named slot overriding of dynamic cvars by @wrabit in #297 as reported in #295
  • Documentation - temperature unit symbols on Components page by @bartoszpiech in #289

New Contributors

Full Changelog: 2.1.2...2.1.3

2.1.2

11 May 21:48
50604ff

Choose a tag to compare

Bugfix related to <c-vars />

As reported here, dynamic and non-dynamic cvars of the same attribute name (i.e. action and :action) were being treated as separate attributes leading to a version wrongly being contained in {{ attrs }}.

2.1.1

02 May 20:20

Choose a tag to compare

:attrs bugfix

As mentioned in #285, the new :attrs proxying included cvars.

  • prevented cvars from being in proxied attrs by @wrabit in #286

Full Changelog: 2.1.0...2.1.1