Html¶
- class dsviper.Html¶
Bases:
objectRenders Viper data as HTML, in two stages. Every method is static.
The renderers return a FRAGMENT, not a page: value(), value_pretty(), type(), dsm_definitions() and documents_details() each answer a run of markup carrying CSS class names.
The assemblers wrap one into a page: style() answers a <style> element defining those classes, body() wraps a fragment in a <body>, and document(title, style, body) takes what those two answered and returns a complete page - Html.document(t, Html.style(), Html.body(content)).
Every string a value or a declaration carries is HTML-escaped on the way out, so stored text cannot reach the page as markup.
Note: Not directly instantiable.
- static body(content: str) str¶
Wrap a rendered fragment in a <body> element, for document().
content is inserted as it is, not escaped: pass a fragment a renderer answered.
- static document(title: str, style: str, body: str) str¶
Return a complete HTML page.
title is HTML-escaped. style and body are what style() and body() answered; they are inserted as they are, not wrapped or escaped again.
- static documents_details(documents: list[DocumentNode], show_type: bool = False) str¶
Return the document trees - the roots DocumentNode.create_documents() answered - as nested markup: a node holding others is a <details> the reader opens, and a leaf is a <div> row.
With show_type, each row carries its element type.
- static dsm_definitions(definitions: DSMDefinitions, show_documentation: bool = False, show_runtime_id: bool = False) str¶
Return the HTML representation of the DSMDefinitions.
- static style() str¶
Return a <style> element defining the CSS classes the renderers emit.
Pass it to document(), or substitute your own sheet defining the same classes.