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
andHtmlEscaper
to escape strings for use in string literals and HTML elements respectively. - Provides functions for creating common tags.
Macros
Structs
- Writes the default HTML5
<meta>
tags. - Writes the HTML5 doctype.
- Represents something that is “empty”
- Html string
- Html text string
- Represents the environment inside a tag.
- Represents a sum of two types.
- Represents a tag that is being opened.
Enums
- Represents the compactability of a tag.
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
- Tells whether the given string is a valid attribute name.