Repository navigation
Portals, class:merge, security fix + docs in markdown
Portals
A component can now keep its own script, stylesheet or Alpine.data definition and send it to the layout. <c-portal name="head" /> marks the spot, <c-portal to="head">...</c-portal> pushes to it. A push block renders once per page however many times the component is used, multiple sends it on every render. No middleware, works with render_to_string, render_component and only components. See the Component Assets tutorial and the c-portal API page. By @wrabit in #383
class:merge
<c-vars class:merge="btn btn-primary" /> appends the parent's classes to the component's own instead of replacing them, with :class merging the same way.
What's Changed
- Security: a dynamic attribute value wrapped in double quotes could still inject attributes, a follow-up to the 2.7.1 fix.
ensure_quoted()now only treats a value as already quoted when it has no inner double quotes. By @patrick-immometrica in #376 - With
DEBUG = True, errors raised inside a component showed up asTypeError: cannot unpack non-iterable NoneType objectinstead of the real exception. Cotton tokens now carry positions, and the debug page highlights the right place. By @patrick-immometrica in #375 - Template compilation is linear instead of quadratic in template size, a big win on large pages, cold starts and every change in dev. By @patrick-immometrica in #379
- Components in one template share a single library snapshot rather than each holding a copy, roughly halving retained memory on component-heavy templates. By @patrick-immometrica in #377
Docs
- The Core docs are written in markdown. Every page is also served raw at
/docs/<slug>.mdand indexed at https://django-cotton.com/llms.txt for AI tools, closing the ask in #284. By @wrabit in #381 - New API section, one page per reserved term, and a trimmed Components walkthrough. By @wrabit in #382
- Dynamic attributes, attrs and c-vars rewritten around one model. By @wrabit in #374
- Add django-cotton-gallery to the ecosystem page by @velezanthony in #373
New Contributors
- @patrick-immometrica made their first contribution in #375
- @velezanthony made their first contribution in #373
Full Changelog: 2.8.0...2.9.0