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
andHtmlEscaper
to escape strings for use in string literals and HTML elements respectively. - tags
- Provides functions for creating common tags.
Macros§
Structs§
- Default
Meta - Writes the default HTML5
<meta>
tags. - Doctype
- Writes the HTML5 doctype.
- Empty
- Represents something that is “empty”
- HtmlStr
- Html string
- Html
Text Str - Html text string
- Inside
TagHtml - 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.
- Attribute
Name - Represents a name of an attribute.
- Attribute
Value - 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.
- ToHtml
String - Something that can be converted into an HTML string.
Functions§
- is_
valid_ attribute_ name - Tells whether the given string is a valid attribute name.