Skip to content

API Reference parrot_formdesigner.ui.templates

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.ui.templates

View source

HTML page templates and CSS for parrot-formdesigner HTTP handlers.

All template builders accept an optional prefix argument (default ""). When the form-designer routes are mounted behind a URL prefix via setup_form_routes(app, prefix="/form"), callers resolve the prefix with request.app.get("_form_prefix", "") and pass it through so that every rendered link and JS fetch() target matches the real route.

Extracted from examples/forms/form_server.py.

Attribute CSS

Function error_page

Return an error page body.

error_page(message: str, prefix: str = '', tenant: str = '') -> str

Parameter Type Default Description
message str Human-readable error message.
prefix str '' URL prefix where the form-designer is mounted.
tenant str '' FEAT-421 — the URL-declared tenant, embedded in the "Go back" link so it stays on the same tenant.

Returns: str — HTML body string with the error banner.

Function form_page

Return the HTML body wrapping a rendered form fragment.

form_page(form_fragment: str) -> str

Parameter Type Default Description
form_fragment str Rendered HTML5 form fragment.

Returns: str — HTML body string with the form wrapped in a card.

Function gallery_page

Return the HTML body for the gallery page.

gallery_page(form_items_html: str) -> str

Parameter Type Default Description
form_items_html str Pre-rendered HTML for the form list items. The caller (FormPageHandler.gallery) is responsible for prefixing hrefs inside this fragment — gallery_page never touches URLs.

Returns: str — HTML body string for the gallery page.

Function index_page

Return the HTML body for the index page (prompt builder + DB loader).

The embedded JavaScript declares a FORM_PREFIX constant so all fetch() calls and window.location.href redirects respect the mount point configured via setup_form_routes(..., prefix=...).

index_page(prefix: str = '', tenant: str = '') -> str

Parameter Type Default Description
prefix str '' URL prefix where the form-designer is mounted.
tenant str '' FEAT-421 — the URL-declared tenant, embedded in the create-form/load-from-db fetch() calls so they hit the tenant-qualified API routes.

Returns: str — HTML body string for the landing page.

Function page_shell

Wrap body HTML in a full page shell.

Injects an authentication script that reads the JWT from localStorage and attaches it as an Authorization: Bearer header on every fetch() call targeting the form-designer API. If no token is present the user is redirected to /admin.

page_shell(title: str, body: str, locale: str = 'en', nav: bool = True, prefix: str = '', tenant: str = '') -> str

Parameter Type Default Description
title str Page title shown in the browser tab.
body str Inner HTML content.
locale str 'en' HTML lang attribute value.
nav bool True Whether to include the top navigation links.
prefix str '' URL prefix where the form-designer is mounted. Empty string = legacy behaviour (routes at root).
tenant str '' FEAT-421 — the URL-declared tenant, embedded in the top navigation's "New Form"/"Gallery" links so they stay on the same tenant rather than dropping the segment.

Returns: str — Complete HTML page string.

Function schema_page

Return the HTML body for the JSON Schema view page.

schema_page(form_uid: str, title: str, schema_json: str, style_json: str, prefix: str = '', tenant: str = '') -> str

Parameter Type Default Description
form_uid str The form's immutable UUID (FEAT-389) — used to build the "View Form" / API Endpoint links below, which must match the {form_uid}-keyed UI and REST routes.
title str Human-readable form title.
schema_json str Pretty-printed JSON Schema string.
style_json str Pretty-printed Style Schema string.
prefix str '' URL prefix where the form-designer is mounted.
tenant str '' FEAT-421 — the form's tenant, embedded in the "View Form" link and the API Endpoints help text so both stay accurate against the tenant-qualified route table.

Returns: str — HTML body string with the JSON schema display.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally