Releases: wrabit/django-cotton
2.6.0
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.
2.5.1
Improved support of nested tags containing quotes
- Enhance
smart_tokenizefunction to better support nested tags and quotes (Fixes #321) by @SamuelJennings in #322
New Contributors
- @SamuelJennings made their first contribution in #322
Full Changelog: 2.5.0...2.5.1
2.5.0 - render_component()
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
- Render component helper by @wrabit in #320
- fix(docs): hide new popover in page load by @wrabit in #319
Full Changelog: 2.4.0...2.5.0
2.4.0 - Native tag support
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:
Full Changelog: 2.3.1...2.4.0
2.3.1
2.3.0
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
- Support nested tags via tokenizer by @wrabit in #309
- Supports nested tags in DEBUG mode by @wrabit in #312
This fixes:
Makes way for:
2.1.4 - Support Django 6.0
What's Changed
- Add support for Django 6 by @hyperNURb in #306
- Typo: Show Size/ Shoe Size by @Tobi7684 in #301
New Contributors
- @Tobi7684 made their first contribution in #301
- @hyperNURb made their first contribution in #306
Full Changelog: 2.1.3...2.1.4
2.1.3
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
- @bartoszpiech made their first contribution in #289
Full Changelog: 2.1.2...2.1.3
2.1.2
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 }}.