diff options
author | Ashelyn Rose <git@ashen.earth> | 2025-04-26 15:05:04 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2025-04-26 15:05:04 -0600 |
commit | 57f68899cd2200568c53201c6fd1ced85b613a3b (patch) | |
tree | 2e5eab21e377ff5833bccf8e9f05ac07729ad336 /modules/site_test | |
parent | 9f29a187b2395c5d1d4039600917e642948ad26b (diff) |
macro handles components now
Diffstat (limited to 'modules/site_test')
-rw-r--r-- | modules/site_test/src/main.rs | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/modules/site_test/src/main.rs b/modules/site_test/src/main.rs index ba40ede..9201c8a 100644 --- a/modules/site_test/src/main.rs +++ b/modules/site_test/src/main.rs @@ -1,21 +1,15 @@ -use std::collections::HashMap; - use morgana::{morx, Component, RenderNode}; pub fn main() { - let parent = ParentLayout { - children: vec![ - RenderNode::Component( - Box::new(Child { - children: vec![ - RenderNode::TextNode { content: "Hello world!".to_string() } - ] - }) - ) - ] + let parent = morx! { + ParentLayout { + Child { + "Hello world!" + } + } }; - let text = morgana::render_tree_blocking(RenderNode::Component(Box::new(parent))); + let text = morgana::render_tree_blocking(parent); println!("{text}") } @@ -24,7 +18,7 @@ struct ParentLayout { } impl Component for ParentLayout { - fn render(self: Box<Self>) -> Vec<RenderNode> { + fn render(self: Box<Self>) -> RenderNode { morx!{ html lang = "en-US" { head { @@ -41,13 +35,9 @@ struct Child { } impl Component for Child { - fn render(self: Box<Self>) -> Vec<RenderNode> { - vec![ - RenderNode::Element { - name: "p".to_string(), - attributes: HashMap::new(), - children: self.children - } - ] + fn render(self: Box<Self>) -> RenderNode { + morx! { + p= {self.children} + } } } |