Display users
This commit is contained in:
parent
e86d1e33b7
commit
c9b96a236a
|
@ -9,12 +9,14 @@ use rocket_contrib::templates::Template;
|
|||
#[derive(Serialize)]
|
||||
struct TemplateContext {
|
||||
parent: &'static str,
|
||||
users: Vec<&'static str>,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Template {
|
||||
let template_context = TemplateContext {
|
||||
parent: "layout",
|
||||
users: vec!["foo", "bar", "car"],
|
||||
};
|
||||
|
||||
Template::render("index", &template_context)
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
{{#*inline "page"}}
|
||||
|
||||
<h1>Hello, World!</h1>
|
||||
<h1>Users</h1>
|
||||
|
||||
<ul>
|
||||
{{#each users}}
|
||||
<li>{{ this }}</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
{{/inline}}
|
||||
{{~> (parent)~}}
|
||||
|
|
Reference in New Issue