File: dynamic.rs

package info (click to toggle)
rust-markup 0.13.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 128 kB
  • sloc: makefile: 4
file content (34 lines) | stat: -rw-r--r-- 631 bytes parent folder | download
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
markup::define! {
    Tabs<'a>(tabs: &'a [Tab<'a>]) {
       @for tab in tabs.iter() {
            @tab
       }
    }

    Tab<'a>(
        title: &'a str,
        body: markup::DynRender<'a>,
    ) {
        h1 { @title }
        div { @body }
    }
}

fn main() {
    let tabs = [
        Tab {
            title: "Home",
            body: markup::new! {
                p { "This is the home page." }
            },
        },
        Tab {
            title: "About",
            body: markup::new! {
                p { "This is the about page." }
            },
        },
    ];

    println!("{}", Tabs { tabs: &tabs })
}