Crate hamlet

Source
Expand description

Provides token definitions for HTML stream processing. The goal of this library is to provide a simple API over which higher abstraction can be built on.

§Example

#[macro_use]
extern crate hamlet;

use std::fmt::Write;

fn main() {
    use hamlet::Token;
    let tokens = vec![
        Token::text("Hello, "),
        Token::start_tag("small", attrs!(class="foo")),
        Token::text("world!"),
        Token::end_tag("small"),
    ];

    let mut html = String::from("");
    for token in tokens {
        write!(html, "{}", token);
    }

    assert_eq!(html, "Hello, <small class=\"foo\">world!</small>");
}

Modules§

attr
Contains structs for defining attributes on elements.
util
Currently contains just a semi-private utility function to support the attrs! macro.

Macros§

attrs
A convenience macro for AttributeList construction. It does not check for duplicates in attribute names. Attribute names with hyphens should be camel-cased.

Enums§

Token
An HTML token, these are representations of everything needed to generate an HTML document.