exlab_wizard.ui.pages.template_editor#
Template authoring editor page (Frontend Spec §5 GUI).
The author-time counterpart to exlab_wizard.ui.pages.templates: where
the manager lists / scaffolds templates, this page opens one template
directory and lets the operator edit its copier.yml (questions), edit its
inline text files, upload binary / rendered files, and delete files. Every
disk mutation lives in the callbacks (wired in exlab_wizard.ui.mount)
that delegate to the exlab_wizard.template.authoring service; this
module only reads the template (manifest + file list + lint findings) to
render and routes operator actions back to those callbacks.
render_template_editor() follows the same pure-view-with-payload
contract as exlab_wizard.ui.pages.templates.render_template_manager():
when NiceGUI is unavailable it returns a plain payload dict (so the view is
unit-testable headless); otherwise it builds the NiceGUI widget tree. Every
widget carries a data-testid for the browser e2e suite.
Functions
|
Render the single-template authoring editor. |
- exlab_wizard.ui.pages.template_editor.render_template_editor(*, template_dir, on_save_manifest=None, on_save_content=None, on_upload=None, on_delete=None, on_back=None)[source]#
Render the single-template authoring editor.
The view loads
template_dir(manifest, file list, lint findings) and renders a header + lint banner, a file list with per-row edit / delete actions, an inline text editor, a question form, and an upload widget. All disk mutation is delegated to the callbacks:on_save_manifest(manifest)– persist a rebuiltTemplateManifest(the question form preserves the loaded manifest’s non-question_exlab_*fields and replaces only its questions).on_save_content(rel, text)– write an edited text file.on_upload(filename, data, render_as_template)– store an upload.on_delete(rel)– remove a file.on_back()– leave the editor.
Every callback is optional; when
Nonethe corresponding action is a no-op so the function still renders (and returns its payload headless) without raising.- Return type:
- Returns:
The NiceGUI root card, or – when NiceGUI is unavailable – the headless payload dict from
_build_payload().- Parameters: