Expand description
Admin-side editor rendering for WidgetKind::Stream widgets.
The page-edit form pre-renders the entire stream editor HTML in
Rust before passing it through Tera — mirrors the existing
Widget::custom_html stash pattern in src/admin/handlers.rs.
The output is one big string of <div data-stream-block> nodes
plus <template> clones the client-side JS uses on insert.
§Walk shape
Top-level entrypoint: render_stream_editor.
For each existing block in the stored JSON:
- Look up the
crate::Blockvia the registry. - Render its header (icon + verbose_name + reorder/remove buttons).
- Render its body — one wrapper per
crate::BlockField:Widget: build a one-offcrate::Widgetwithname = ""so it doesn’t accidentally submit, then call the existingwidgets::render(w)Tera macro.Stream/Repeat: recurse.Computed: render inline via the field’s render fn.
For each registered block type, render an empty-block clone
into a <template data-block-template="X"> element — the JS
clones these on insert so new blocks land with the right shape
without an admin round-trip.
§Form submission
Every nested <input> / <select> / <textarea> is rendered with
name="" so the browser skips it on submit per HTML5
§ 4.10.18.3 (5.5). Only the single hidden <input> carrying the
serialized JSON tree (name="{stream_name}") participates in the
POST. The JS rewrites this hidden value on every input event.
Structs§
- Picker
Option - Picker option metadata stamped into the page-edit Tera context.
The block-picker dialog reads from
picker_optionsand filters bydata-allowedat click time.
Functions§
- picker_
options - Build the picker-option list from the global registry. Stamped
into Tera context as
picker_optionsbypage_edit_form. - render_
stream_ editor - Top-level entry: render the entire editor HTML for one
WidgetKind::Streamwidget. - render_
stream_ editor_ with render_stream_editorwith a page-builder dyn-block overlay: UI-defined block types resolve throughdyn_setbefore the inventory registry, so their entries + clone-templates render exactly like code blocks —stream_editor.jsneeds no changes.- render_
widget_ via_ macro - Render a single widget by calling the existing
widgets::render(w)Tera macro — same path the rest of the admin uses. We thread it through a one-shot inline template so we get the exact same HTML. - render_
widget_ via_ macro_ with render_widget_via_macrowith an explicit block picker. AStreamwidget’s_widget.htmlarm readspicker_optionsfrom context to populate its block-picker dialog; the plain macro path leaves it empty. Page-builder flex zones / repeaters need their allowed dyn blocks in the picker so editors can add entries.