Display users
This commit is contained in:
parent
e86d1e33b7
commit
c9b96a236a
|
@ -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)
|
||||||
|
|
|
@ -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)~}}
|
||||||
|
|
Reference in New Issue