| Crates.io | html_export |
| lib.rs | html_export |
| version | 0.1.1 |
| created_at | 2025-03-17 15:28:44.892376+00 |
| updated_at | 2025-03-18 08:28:07.810824+00 |
| description | Basic struct & enums to html file conversion crate |
| homepage | https://github.com/Hodson-Thomas/Rust-Html-Export/wiki |
| repository | https://github.com/Hodson-Thomas/Rust-Html-Export |
| max_upload_size | |
| id | 1595609 |
| size | 236,526 |
A simple rust crate to convert structure, enums, data structures into html files.
This crate is designed to:
This crate is not designed to:
Be implemented in frameworks
Be implemented in web applications
use html_export::{
element::{Element, HtmlElement, HtmlElementConfig},
html::ToHtml,
tags::TagType,
};
pub struct Person {
pub name: String,
pub age: u8,
}
impl ToHtml for Person {
fn to_html(&self) -> Element {
let mut div = Element::Element(HtmlElement::new(
TagType::Div,
HtmlElementConfig::new_empty(),
));
div += Element::Element(HtmlElement::new(TagType::P, HtmlElementConfig::new_empty()))
+ Element::Text(format!("{} is {} years old.", self.name.clone(), self.age));
div
}
}
fn main() {
let person = Person {
name: "Thomas Hodson".to_string(),
age: 22,
};
let html = person.to_html();
}
Please check out the Wiki.