Use fully working examples in dyn_templates.

Closes #1992.
This commit is contained in:
Sergio Benitez 2022-03-03 15:41:29 -08:00
parent 91e3b4397a
commit b5b842f0bf
2 changed files with 12 additions and 13 deletions

View File

@ -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.

View File

@ -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