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