From 44075cee1fa9621623aeb9382150b4c308ffe8ef Mon Sep 17 00:00:00 2001 From: Raine Date: Sat, 14 Oct 2023 22:39:16 +0200 Subject: [PATCH] feat: add element macro --- src/dom/element/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dom/element/mod.rs b/src/dom/element/mod.rs index e43fce8..a5ce29b 100644 --- a/src/dom/element/mod.rs +++ b/src/dom/element/mod.rs @@ -11,6 +11,14 @@ pub struct Element { pre_text: String, } +#[macro_export] +macro_rules! element { + ($el:literal$(, $($content: expr),*)?) => { + Element::new($el) + $($(.append_child($content))*)? + }; +} + impl Element { pub fn new>(t: S) -> Self { Element {