vibe.web_core.rendering

Web UI Dynamic Content Rendering.

Functions responsible for generating HTML fragments for the dynamic parts of the web interface, primarily for HTMX responses. Includes: - Rendering the preview area content. - Rendering the initial set of question divs. - Creating OOB (Out-of-Band) swap HTML snippets based on state changes. - Rendering individual list items dynamically. - Relies on DataTypeHandlers for rendering individual question widgets.

GroupRenderItem

Render-ready data for a grouped question section.

build_toolbar_context

build_toolbar_context(status: str, has_appendices: bool = False, appendices_info: list[dict[str, Any]] | None = None, has_assistants: bool = False, assistants_info: list[dict[str, Any]] | None = None, template_data: TemplateData | None = None, assistant_dev: dict[str, Any] | None = None) -> dict[str, Any]

Create a consistent toolbar context for layout templates.

get_error_template

get_error_template() -> Template

Get the Jinja template for rendering error messages.

Returns:
  • Template

    Jinja Template object for error area HTML rendering

render_partial_preview

render_partial_preview(template: TemplateData, preview_context: NestedValue, needed_vars_paths: list[str], questions: dict[str, Any]) -> str

Render the template with available answers (from NestedValue) and user-friendly placeholders.

Use the provided template object and question definitions (keyed by path). Handle potential rendering errors gracefully. Return HTML content for the preview.

render_initial_question_divs

render_initial_question_divs(original_question_order_paths: list[str], relevant_questions_paths: list[str], current_answers_root: NestedValue, questions: dict[str, Any], followup_placements: dict[str, Any], all_followup_ids: set[str], validation_errors: dict[str, Any]) -> str

Render the initial structure for the questions container using DataTypeHandlers.

Include visible divs for relevant questions and hidden, empty divs for irrelevant ones. Pass validation errors to the widgets. Use the helper function. Now supports grouping questions by appendix.

render_grouped_questions_html

render_grouped_questions_html(groups: list[GroupConfig], relevant_questions_paths: list[str], current_answers_root: NestedValue, questions: dict[str, Any], followup_placements: dict[str, Any], validation_errors: dict[str, Any], *, layout: str, visible_group_ids: list[str], template_id: str = '', version_identifier: str = '', group_statuses: dict[str, GroupStatus] | None = None, progress_indicator: str = 'none', group_progress: dict[str, Any] | None = None, paged_ctx: dict[str, Any] | None = None) -> str

Render grouped questions for accordion/tabs/flat/paged layouts.

Groups with no relevant questions are still included in the context but marked as not visible, allowing layout templates to decide how to handle them.

create_oob_swaps

create_oob_swaps(final_status: str, output_html_inner: str, became_relevant_paths: set[str], became_irrelevant_paths: set[str], current_answers_root: NestedValue, questions: dict[str, Any], validation_errors: dict[str, Any], previous_validation_errors: dict[str, Any], followup_placements: dict[str, Any], current_relevant_blocks_set: set[str], template_id: str, version_identifier: str = '') -> list[str]

Create a list of HTMX OOB swap HTML strings based on the processing results.

Use DataTypeHandlers for rendering widgets via the helper function. Now supports appendix preview tabs and enhanced download options.