mirror of https://github.com/rwf2/Rocket.git
parent
91e3b4397a
commit
b5b842f0bf
|
@ -35,17 +35,17 @@ supports [Handlebars] and [Tera].
|
||||||
last two extensions**:
|
last two extensions**:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use rocket_dyn_templates::Template;
|
use rocket_dyn_templates::{Template, context};
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
fn index() -> Template {
|
||||||
|
Template::render("template-name", context! { field: "value" })
|
||||||
|
}
|
||||||
|
|
||||||
#[launch]
|
#[launch]
|
||||||
fn rocket() -> _ {
|
fn rocket() -> _ {
|
||||||
rocket::build().attach(Template::fairing())
|
rocket::build().attach(Template::fairing())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
|
||||||
fn index() -> Template {
|
|
||||||
Template::render("template-name", &context)
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
See the [crate docs] for full details.
|
See the [crate docs] for full details.
|
||||||
|
|
|
@ -26,18 +26,17 @@
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # #[macro_use] extern crate rocket;
|
//! # #[macro_use] extern crate rocket;
|
||||||
//! use rocket_dyn_templates::Template;
|
//! use rocket_dyn_templates::{Template, context};
|
||||||
|
//!
|
||||||
|
//! #[get("/")]
|
||||||
|
//! fn index() -> Template {
|
||||||
|
//! Template::render("template-name", context! { field: "value" })
|
||||||
|
//! }
|
||||||
//!
|
//!
|
||||||
//! #[launch]
|
//! #[launch]
|
||||||
//! fn rocket() -> _ {
|
//! fn rocket() -> _ {
|
||||||
//! rocket::build().attach(Template::fairing())
|
//! rocket::build().attach(Template::fairing())
|
||||||
//! }
|
//! }
|
||||||
//!
|
|
||||||
//! #[get("/")]
|
|
||||||
//! fn index() -> Template {
|
|
||||||
//! # let context = ();
|
|
||||||
//! Template::render("template-name", &context)
|
|
||||||
//! }
|
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! ## Naming
|
//! ## Naming
|
||||||
|
|
Loading…
Reference in New Issue