use crate::html::Render; #[allow(non_camel_case_types)] pub(crate) struct h1 { text: String, } impl Render for h1 { fn render(&self) -> String { format!("

{}

", self.text) } } impl h1 { pub(crate) fn new(text: String) -> Self { Self { text } } } #[allow(non_camel_case_types)] pub(crate) struct h2 { text: String, } impl Render for h2 { fn render(&self) -> String { format!("

{}

", self.text) } } impl h2 { pub(crate) fn new(text: String) -> Self { Self { text } } } #[allow(non_camel_case_types)] pub(crate) struct link { rel: &'static str, href: &'static str, } impl Render for link { fn render(&self) -> String { format!("", self.rel, self.href) } } impl link { pub(crate) fn new(rel: &'static str, href: &'static str) -> Self { Self { rel, href } } } #[allow(non_camel_case_types)] pub(crate) struct div { id: &'static str, classes: Vec<&'static str>, content: Vec>, } impl Render for div { fn render(&self) -> String { let classes = self.classes.join(" "); format!( "
{}
", self.id, classes, self.content.render() ) } } impl div { pub(crate) fn new(id: &'static str, classes: Vec<&'static str>) -> Self { Self { id, classes, content: vec![], } } pub(crate) fn append_element(&mut self, element: impl Render + 'static) { self.content.push(Box::new(element)); } } #[allow(non_camel_case_types)] pub(crate) struct p { id: &'static str, classes: Vec<&'static str>, text: String } impl Render for p { fn render(&self) -> String { let classes = self.classes.join(" "); format!("

{}

", self.id, classes, self.text) } } impl p { pub(crate) fn new(id: &'static str, classes: Vec<&'static str>, text: String) -> Self { Self { id, classes, text } } } #[allow(non_camel_case_types)] pub(crate) struct img { id: &'static str, classes: Vec<&'static str>, src: &'static str, } impl Render for img { fn render(&self) -> String { let classes = self.classes.join(" "); format!("", self.id, classes, self.src) } } impl img { pub(crate) fn new(id: &'static str, classes: Vec<&'static str>, src: &'static str) -> Self { Self { id, classes, src } } } #[allow(non_camel_case_types)] pub(crate) struct a { id: &'static str, classes: Vec<&'static str>, href: &'static str, text: String, } impl Render for a { fn render(&self) -> String { let classes = self.classes.join(" "); format!("{}", self.id, classes, self.href, self.text) } } impl a { pub(crate) fn new(id: &'static str, classes: Vec<&'static str>, href: &'static str, text: String) -> Self { Self { id, classes, href, text } } }