Crate write_html

Source
Expand description

This crate provides a way to write HTML with as little overhead as possible.

This crate is still in development, and the API is not stable.

§Example

use write_html::*;

let page = html!(
    (Doctype)
    html lang="en" {
        head {
            (DefaultMeta)
            title { "Website!" }
        }
        body {
            h1 #some-id { "H1" }
            h2 { "H2" }
            h3 { "H3" }
            p { "Paragraph" }
            ol {
                li { "Item 1" }
                li { "Item 2" }
                li style="color: red" { "Item 3" }
            }
            footer;
        }
    }
).to_html_string().unwrap();

Modules§

escapes
Provides StringEscaper and HtmlEscaper to escape strings for use in string literals and HTML elements respectively.
tags
Provides functions for creating common tags.

Macros§

html

Structs§

DefaultMeta
Writes the default HTML5 <meta> tags.
Doctype
Writes the HTML5 doctype.
Empty
Represents something that is “empty”
HtmlStr
Html string
HtmlTextStr
Html text string
InsideTagHtml
Represents the environment inside a tag.
Sum
Represents a sum of two types.
TagOpening
Represents a tag that is being opened.

Enums§

Compactability
Represents the compactability of a tag.

Traits§

AsHtml
Something that can be converted into HTML.
AttributeName
Represents a name of an attribute.
AttributeValue
Represents a value of an attribute.
Attributes
Represents a list of attributes.
Html
Represents a content that can be written to a Write as HTML.
HtmlEnv
Represents an environment that can write HTML.
ToHtmlString
Something that can be converted into an HTML string.

Functions§

is_valid_attribute_name
Tells whether the given string is a valid attribute name.