Module html

Source
Expand description

HTML rendering utilities.

This module provides structures and methods for creating and rendering HTML content.

§Examples

§Creating and rendering an HTML Tag

use cot::html::HtmlTag;

let tag = HtmlTag::new("br");
let html = tag.render();
assert_eq!(html.as_str(), "<br />");

§Adding Attributes to an HTML Tag

use cot::html::HtmlTag;

let mut tag = HtmlTag::new("input");
tag.attr("type", "text").attr("placeholder", "Enter text");
tag.bool_attr("disabled");
assert_eq!(
    tag.render().as_str(),
    "<input type=\"text\" placeholder=\"Enter text\" disabled />"
);

Structs§

Html
A type that represents HTML content as a string.
HtmlTag
A helper struct for rendering HTML tags.