render

Function render 

Source
pub fn render(tree: &Tree<'_>) -> String
Expand description

Render a Tree to an HTML string.

This functions ignore comments and render template blocks (expressions are statements) as raw strings with no spaces inside their delimiters (will render {{expr}} even if it was {{ expr }}, {!expr!} even if it was {! expr !} and {%stmt%} even if it was {% stmt %}).

let html = r#"<main><!-- A comment which will be ignored -->
    <p>A paragraph</p>
    <img src="/link/to/image">
    {{ expr }}
</main>"#;
let tree = pochoir_parser::parse("index.html", html)?;
let rendered_html = pochoir_parser::render(&tree);

assert_eq!(rendered_html, r#"<main>
    <p>A paragraph</p>
    <img src="/link/to/image">
    {{expr}}
</main>"#);