Skip to content

Releases: wrabit/django-cotton

2.1.3

30 Jun 17:34
Compare
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
Compare
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
Compare
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

2.1.0

29 Apr 07:39
6e05059
Compare
Choose a tag to compare

Support setting attrs with :attrs and proxying

  • You can now provide the attrs dictionary from other components or view context using :attrs on the component tag, <c-child :attrs="some_attrs_from_parent" />
  • Also supported is the proxying of attrs through components using :attrs="attrs"

Many thanks to @Dresdn and others who have contributed to the idea.

New Contributors

Full Changelog: 2.0.3...2.1.0

2.0.3

01 Apr 10:40
Compare
Choose a tag to compare

Adds support for Django 5.2

  • Run tests with multiple Python / Django versions combinations by @alorence in #274

Full Changelog: 2.0.1...2.0.3

2.0.1

19 Mar 08:58
Compare
Choose a tag to compare

Changed default behaviour of context isolation to non-isolated

  • The last release creates an undesirable effect where context processors are re-generated on each component render (issue) which in some cases can have negative side effects depending on how you are using them. For the time being it's safer to revert the default behaviour until the issue can be thoroughly looked into and resolved.
  • turned off context isolation by default by @wrabit in #270

Full Changelog: v2.0.0...2.0.1

2.0.0

11 Mar 18:34
ecdb419
Compare
Choose a tag to compare

Component context isolation by default

Although this doesn't bring much in terms of new functionality, there is a risk of it being a breaking change due to the change in default behaviour so thorough testing of this version in your project is highly recommended before deploying it to production.

Explanation

Currently, variables defined in a parent view or component are implicitly made available to all child components whether you have passed them as attributes or not.

This can result in data unintentionally leaking across components sometimes leading to hard-to-trace side effects.

An example of the problem:

Imagine a variable title that has been made available to a component or view template called parent.html.

<!-- parent.html -->
{{ title }}
<c-child />

The child component also uses a variable named title:

<!-- child.html -->
{{ title }}

Before this release, parent's title is automatically made available to the child component. If it's intended that the child should have its own unique title, it becomes very easy to miss if we have forgotten to provide a title to child as it would use the title from parent context.

From now on title from the parent would not be available in the child - it should be passed explicitly as an attribute, like:

<!-- parent.html -->
<c-child title="{{ child_title }}" />

Summarising benefits of this approach:

  • Missing variables will be more obvious to spot in development as context from other views and components cannot interfere.
  • Defining attributes keeps data dependencies well defined making it clear to see what data components rely on, making jobs like refactoring and understanding easier.

Context processor context stays

Keeping a balance between component isolation whilst keeping some of the automatic benefits of Django Templates, data from any enabled context processor (builtin or custom) will remain available. (i.e. {{ user }}, {{ request }}, {{ messages }}, {{ perms }})

1.6.0

02 Mar 13:39
fed7258
Compare
Choose a tag to compare

Create default component with index.html

We've introduced the ability to choose a default component when calling a directory path by using an index.html.

Docs

Before:

- cotton
  - card
    - header.html
    - card.html


<c-card.card>
  <c-card.header />
</c-card.card>

After:

- cotton
  - card
    - header.html
    - index.html


<c-card>
  <c-card.header />
</c-card>

Full Changelog: 1.5.3...1.6.0

1.5.3

17 Feb 18:04
Compare
Choose a tag to compare

Fix non-dynamic attributes on cvars

  • Fixes parsing of non-dynamic attributes in cvars by @wrabit in #251

Previously we were still template-parsing non-dynamic attributes on <c-vars />. So this:

<c-vars attribute1="None" attribute2="False" attribute3="1" />

Would give us the python types None, False, 1 respectively. Even though if these were attributes on the component, they would have correctly been provided as strings. As raised in #249.

Full Changelog: v1.5.2...1.5.3

v1.5.2

10 Jan 13:23
Compare
Choose a tag to compare

Allow valid json to be passed inside attributes

  • Handle attributes containing quoted spaces by @wrabit in #241

Previously, passing a space inside a quoted string inside an attribute value would produce a malformed string due to the way Django understands attributes on a templatetag. Cotton's underlying component templatetag now handles this as expected.

In reference to:

Full Changelog: v1.5.1...v1.5.2