Add layout
This commit is contained in:
parent
6c0837c675
commit
e86d1e33b7
5 changed files with 52 additions and 1 deletions
14
Cargo.lock
generated
14
Cargo.lock
generated
|
@ -294,6 +294,9 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"rocket",
|
||||
"rocket_contrib",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1033,6 +1036,17 @@ version = "1.0.116"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5"
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.116"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.24",
|
||||
"quote 1.0.7",
|
||||
"syn 1.0.44",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.59"
|
||||
|
|
|
@ -14,6 +14,9 @@ publish = true
|
|||
|
||||
[dependencies]
|
||||
rocket = "0.4.5"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
||||
[dependencies.rocket_contrib]
|
||||
version = "0.4.5"
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -1,12 +1,23 @@
|
|||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
|
||||
#[macro_use] extern crate rocket;
|
||||
#[macro_use] extern crate serde_derive;
|
||||
extern crate rocket_contrib;
|
||||
|
||||
use rocket_contrib::templates::Template;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct TemplateContext {
|
||||
parent: &'static str,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Template {
|
||||
Template::render("index", &1)
|
||||
let template_context = TemplateContext {
|
||||
parent: "layout",
|
||||
};
|
||||
|
||||
Template::render("index", &template_context)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
{{#*inline "page"}}
|
||||
|
||||
<h1>Hello, World!</h1>
|
||||
|
||||
{{/inline}}
|
||||
{{~> (parent)~}}
|
||||
|
|
18
templates/layout.html.hbs
Normal file
18
templates/layout.html.hbs
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width,
|
||||
initial-scale=1,
|
||||
maximum-scale=1,
|
||||
shrink-to-fit=no,
|
||||
user-scalable=no"/>
|
||||
|
||||
<title>FediHub</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{{~> page}}
|
||||
</body>
|
||||
</html>
|
Reference in a new issue