v.0.9.7
What's Changed
Passing Python data types
Using the :
to prefix an attribute tells Cotton we're passing a dynamic type down. We already know we can use this to send a variable, but you can also send basic python types, namely:
- Integers and Floats
- None
- True and False
- Lists
- Dictionaries
This benefits a number of use-cases, for example if you have a select component that you want to provide some value:
<!-- select.cotton.html -->
<select {{ attrs }}>
{% for option in options %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
</select>
<c-select name="q1" :options="['yes', 'no', 'maybe']" />
<!-- output -->
<select name="q1">
<option value="yes">yes</option>
<option value="no">no</option>
<option value="maybe">maybe</option>
</select>
More
- Literal eval on ":" attrs and vars by @wrabit in #19
- #16
- https://django-cotton.com/docs/components#python-types
Full Changelog: v.0.9.6...v.0.9.7