1
0
Fork 0

Display users

This commit is contained in:
Alex Kotov 2020-10-14 05:22:37 +05:00
parent e86d1e33b7
commit c9b96a236a
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 9 additions and 1 deletions

View File

@ -9,12 +9,14 @@ use rocket_contrib::templates::Template;
#[derive(Serialize)] #[derive(Serialize)]
struct TemplateContext { struct TemplateContext {
parent: &'static str, parent: &'static str,
users: Vec<&'static str>,
} }
#[get("/")] #[get("/")]
fn index() -> Template { fn index() -> Template {
let template_context = TemplateContext { let template_context = TemplateContext {
parent: "layout", parent: "layout",
users: vec!["foo", "bar", "car"],
}; };
Template::render("index", &template_context) Template::render("index", &template_context)

View File

@ -1,6 +1,12 @@
{{#*inline "page"}} {{#*inline "page"}}
<h1>Hello, World!</h1> <h1>Users</h1>
<ul>
{{#each users}}
<li>{{ this }}</li>
{{/each}}
</ul>
{{/inline}} {{/inline}}
{{~> (parent)~}} {{~> (parent)~}}