djust 0.5.3rc1

Pre-releaseReleased

Added

  • Runtime layout switching — self.set_layout(path) (v0.6.0) — Phoenix 1.1 parity. An event handler can swap the surrounding layout template (nav, sidebar, footer, wrapper markup) without a full page reload: inner state — form values, scroll position, focused element, dj-hook bookkeeping, third-party-widget references — is fully preserved because the live [dj-root] element is physically moved from the current body into the new layout rather than re-created. Server side: new LayoutMixin in python/djust/mixins/layout.py composed into the LiveView base, queuing at most one pending path (last-write-wins). WebSocket consumer: new _flush_pending_layout() wired at all nine _flush_page_metadata call sites; renders the layout template with the view's current get_context_data() and emits a {"type": "layout", "path": ..., "html": ...} frame. Graceful degradation: TemplateDoesNotExist or any render exception logs a warning and leaves the WS intact. Client side: new static/djust/src/40-dj-layout.js module registered for the layout WS frame — finds the [dj-root] / [data-djust-root] inside the incoming HTML, splices in the live root node, swaps document.body, and fires a djust:layout-changed CustomEvent on document. Handles missing-root payloads and empty HTML gracefully. Tests: 12 Python cases in tests/unit/test_layout_switching.py (mixin, consumer emit/noop/missing-template/no-mixin/view-none, LiveView composition) + 6 JSDOM cases in tests/js/dj_layout.test.js (root-identity preservation, CustomEvent dispatch, malformed-payload refusal, empty-html noop, [dj-root] fallback, global export). Full user guide at docs/website/guides/layouts.md (linked from _config.yaml and index.md). Known limitation: <head> tags are not merged — if a layout needs new stylesheets, add them to the initial layout's <head>. (python/djust/mixins/layout.py, python/djust/mixins/__init__.py, python/djust/live_view.py, python/djust/websocket.py, python/djust/static/djust/src/03-websocket.js, python/djust/static/djust/src/40-dj-layout.js)

All releases · Atom feed