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 /src | |
parent | 9f29a187b2395c5d1d4039600917e642948ad26b (diff) |
macro handles components now
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 2 | ||||
-rw-r--r-- | src/render.rs | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs index 2aa0d7a..c760338 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ mod render; -pub use render::{Component, RenderNode}; +pub use render::{RenderNode, Component}; pub use morgana_proc::morx; pub async fn render_tree(parent_node: RenderNode) -> String { diff --git a/src/render.rs b/src/render.rs index 94b193b..8addbdb 100644 --- a/src/render.rs +++ b/src/render.rs @@ -4,7 +4,7 @@ use std::future::Future; use futures::future::join_all; pub trait Component { - fn render(self: Box<Self>) -> Vec<RenderNode>; + fn render(self: Box<Self>) -> RenderNode; } pub enum RenderNode { @@ -31,11 +31,9 @@ impl RenderNode { pub(crate) fn render_to_string(self) -> Pin<Box<dyn Future<Output = String>>> { match self { RenderNode::Component(component) => { - let elements = component.render(); + let result_root = component.render(); Box::pin((async move || { - join_all(elements.into_iter() - .map(|child| child.render_to_string()) - .collect::<Vec<_>>()).await.join("") + result_root.render_to_string().await })()) }, |