blob: b0fe9f33aebcf32ea164e614bde13101929ddd4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
use morgana::{morx, Component, RenderNode};
pub fn main() {
let parent = morx! {
ParentLayout {
Child some_prop={"something".to_string()} {
"Hello world!"
}
}
};
let text = morgana::render_tree_blocking(parent);
println!("{text}")
}
struct ParentLayout {
children: Vec<RenderNode>
}
impl Component for ParentLayout {
fn render(self: Box<Self>) -> RenderNode {
let string = "test string";
morx!{
!doctype html;
html lang = "en-US" {
head {
title ={string}
}
body = {self.children}
}
}
}
}
struct Child {
children: Vec<RenderNode>,
some_prop: String,
}
impl Component for Child {
fn render(self: Box<Self>) -> RenderNode {
morx! {
p= {self.children}
p= {self.some_prop}
}
}
}
|