diff --git a/contrib/dyn_templates/README.md b/contrib/dyn_templates/README.md index 57421d3c..c38ce630 100644 --- a/contrib/dyn_templates/README.md +++ b/contrib/dyn_templates/README.md @@ -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. diff --git a/contrib/dyn_templates/src/lib.rs b/contrib/dyn_templates/src/lib.rs index d16dbb72..91764a19 100644 --- a/contrib/dyn_templates/src/lib.rs +++ b/contrib/dyn_templates/src/lib.rs @@ -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