hson_gen

Generate HTML from hson.

Usage

DOM element attributes can be set using the attrs key.
InnerText is set using the text key. ```rust extern crate hsongen; use hsongen::HsonGen;

...

let data = r#" { "doctype": { "attrs": { "html": "" } }, "html": { "head": { "link": { "attrs": { "href": "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css", "rel": "stylesheet" } }, "title": { "text": "Awesome page" } }, "body": { "div": { "attrs": { "class": ["main", "visible"] }, "article": { "attrs": { "class": ["active"] }, "p": { "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." }, "p": { "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." } }, "aside": { "ul": { "attrs": { "class": ["right-bar", "active"] }, "li": { "a": { "attrs": { "href": "https://google.com" }, "text": "Follow ", "b": { "text": "the" }, "text": " Money" } }, "li": { "a": { "attrs": { "href": "https://mozilla.org" }, "text": "Learn more" } } } } } } } } "#;

let mut generator = HsonGen::new(); let html = generator.generate(&data).unwrap();

println!("{}", &html); Generate: HTML Awesome page

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

```