write_scope_html 0.1.0

A write_scope front-end for HTML
Documentation
  • Coverage
  • 4.17%
    1 out of 24 items documented1 out of 22 items with examples
  • Size
  • Source code size: 4.6 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.38 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • krtab/write-html
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • krtab

A [write_scope] library for HTML

Example

# use std::io::{self, stdout};
# use write_scope_html::{Body, Div, Html, HtmlElement, H1, P};
# use write_scope::{Open, WrapIO};
fn main() -> io::Result<()> {
    let w = WrapIO(stdout().lock());
    let html = w.open(Html)?;
    let mut body = html.open(Body)?;
    {
        let id = String::from("toto");
        let mut toto = body.ref_open(Div.id(&id).id("babar"))?.open(Div)?;
        drop(id);
        toto.ref_open(Div.id("toto_1"))?;
        toto.ref_open(Div.id("toto_2"))?;
        toto.close()?;
    }
    body.ref_open(Div.id("tata"))?;
    body.open_scope(Div.id("tutu"), |tutu| {
        tutu.open(H1)?.text("Hello!")?;
        tutu.open(P)?.text("Beautiful morning!")?;
        Ok(())
    })?;
    body.open(Div)?;
    Ok(())
}