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

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

Macros

Structs

Enums

Traits

  • Something that can be converted into HTML.
  • Represents a name of an attribute.
  • Represents a value of an attribute.
  • Represents a list of attributes.
  • Represents a content that can be written to a Write as HTML.
  • Represents an environment that can write HTML.
  • Something that can be converted into an HTML string.

Functions