Skip to main content

HtmlRenderer

Struct HtmlRenderer 

Source
pub struct HtmlRenderer { /* private fields */ }
Expand description

A stateless, streaming HTML renderer. Each render call decodes a self-contained snapshot batch into a transient map, walks it once, and streams HTML text out — zero state retained across calls. A pure function of the opcode stream (Renderer Statelessness).

Implementations§

Source§

impl HtmlRenderer

Source

pub fn new() -> Self

Create a renderer (stateless; the same value serves every render).

Source

pub fn with_debug_comments(self, on: bool) -> Self

Enable/disable debug comments. When on, each rendered node is prefixed with an HTML comment naming its component and the modifiers applied (see [crate::debug]).

Source

pub fn debug_comments(&self) -> bool

Whether debug comments are enabled.

Source

pub fn render_document( &self, opcodes: &[Opcode], strings: &[u8], root: u32, ) -> String

Render the subtree rooted at root as a full HTML document, with the built-in base design inlined as a <style> block (the default for library hosts and tests).

Source

pub fn render_document_with_meta( &self, opcodes: &[Opcode], strings: &[u8], root: u32, meta: &DocumentMeta, ) -> String

Render a full HTML document with host-supplied DocumentMeta (canonical URL, Open Graph/Twitter tags, JSON-LD) and the built-in base design inlined as a <style> block.

The renderer stays stateless: meta is input to this call only. META::SET_WINDOW_METADATA title/description/locale still win over the fallbacks in meta.

Source

pub fn render_document_linked( &self, opcodes: &[Opcode], strings: &[u8], root: u32, css_base: &str, ) -> String

Render the subtree rooted at root as a full HTML document with the built-in base design as a separate content-hashed stylesheet link ({css_base}/{css::builtin_css_name()}) instead of an inline <style> block. css_base is the host’s reserved framework base (e.g. /_pathland); an empty base falls back to the inline document.

Token overrides and fit-band rules stay inline (they are per-session renderer state), after the stylesheet link so they win the cascade.

Source

pub fn render_document_linked_with_meta( &self, opcodes: &[Opcode], strings: &[u8], root: u32, css_base: &str, meta: &DocumentMeta, ) -> String

Source

pub fn render_fragment( &self, opcodes: &[Opcode], strings: &[u8], root: u32, ) -> String

Render the subtree rooted at root as an HTML fragment (no <html>). SET_DESIGN_TOKEN overrides are applied to the document head by render_document; a fragment is assumed to be embedded in a document that already defines the token variables.

Trait Implementations§

Source§

impl Clone for HtmlRenderer

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for HtmlRenderer

Source§

impl Debug for HtmlRenderer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.