What's Changed
Feat
-
Add defaults for the component inputs with the
Component.Defaults
nested class. Defaults
are applied if the argument is not given, or if it set toNone
.For lists, dictionaries, or other objects, wrap the value in
Default()
class to mark it as a factory
function:from django_components import Default class Table(Component): class Defaults: position = "left" width = "200px" options = Default(lambda: ["left", "right", "center"]) def get_context_data(self, position, width, options): return { "position": position, "width": width, "options": options, } # `position` is used as given, `"right"` # `width` uses default because it's `None` # `options` uses default because it's missing Table.render( kwargs={ "position": "right", "width": None, } )
-
{% html_attrs %}
now offers a Vue-like granular control overclass
andstyle
HTML attributes,
where each class name or style property can be managed separately.{% html_attrs class="foo bar" class={"baz": True, "foo": False} class="extra" %}
{% html_attrs style="text-align: center; background-color: blue;" style={"background-color": "green", "color": None, "width": False} style="position: absolute; height: 12px;" %}
Fix
- Fix compat with Windows when reading component files (#1074)
- Fix resolution of component media files edge case (#1073)
Full Changelog: 0.134...0.135