From b5b842f0bf59545a1184295f32f4b4832c532827 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 3 Mar 2022 15:41:29 -0800 Subject: [PATCH] Use fully working examples in dyn_templates. Closes #1992. --- contrib/dyn_templates/README.md | 12 ++++++------ contrib/dyn_templates/src/lib.rs | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) 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