yoshuawuyts / html

Type-safe HTML support for Rust
Apache License 2.0
244 stars 7 forks source link

Add `Builder::{push,extend}` methods #36

Closed yoshuawuyts closed 1 year ago

yoshuawuyts commented 1 year ago

For example using open-graph we would probably want to be able to do:

let tree = html::root::Html::builder()
    .lang("en")
    .head(|head| {
        head.extend(OpenGraph::builder() // takes an `IntoIterator<Item = Into<HeadChild>>`
            .site("@flickr")
            .title("The Rock")
            .type(ObjectType::VideoMovie)
            .image("http://ia.media-imdb.com/images/rock.jpg")
            .build())
    })
    .body(|body| body.text("Hello, world!"))
    .build();