Trait Renderer

Source
pub trait Renderer {
    // Required methods
    fn open(&mut self, tag: &str, attrs: &[(&str, String)]);
    fn close(&mut self, tag: &str);
    fn self_close(&mut self, tag: &str, attrs: &[(&str, String)]);
    fn contents(&mut self, nodes: &[Node]);
    fn cr(&mut self);
    fn text(&mut self, text: &str);
    fn text_raw(&mut self, text: &str);
    fn ext(&mut self) -> &mut RenderExtSet;
}
Expand description

Each node outputs its HTML using this API.

Renderer is a struct that walks through AST and collects HTML from each node into an internal buffer.

Required Methods§

Source

fn open(&mut self, tag: &str, attrs: &[(&str, String)])

Write opening HTML tag with attributes, e.g. <a href="url">.

Source

fn close(&mut self, tag: &str)

Write closing HTML tag, e.g. </a>.

Source

fn self_close(&mut self, tag: &str, attrs: &[(&str, String)])

Write a self-closing HTML tag with attributes, e.g. <img src="url"/>.

Source

fn contents(&mut self, nodes: &[Node])

Loop through child nodes and render each one.

Source

fn cr(&mut self)

Write line break (\n). The default renderer ignores it if the last char in the buffer is \n already.

Source

fn text(&mut self, text: &str)

Write plain text with escaping, <div> -> &lt;div&gt;.

Source

fn text_raw(&mut self, text: &str)

Write plain text without escaping, <div> -> <div>.

Source

fn ext(&mut self) -> &mut RenderExtSet

Extension set to store custom stuff.

Implementors§