From f941b1310b50292749bc030b1bf5e1ef57cdf0f5 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Fri, 10 Aug 2018 23:03:13 -0700 Subject: [PATCH] Improve template engine customization docs. --- contrib/lib/src/templates/mod.rs | 2 +- site/guide/responses.md | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/lib/src/templates/mod.rs b/contrib/lib/src/templates/mod.rs index 24b7e540..6f24c044 100644 --- a/contrib/lib/src/templates/mod.rs +++ b/contrib/lib/src/templates/mod.rs @@ -125,7 +125,7 @@ const DEFAULT_TEMPLATE_DIR: &'static str = "templates"; /// } /// ``` /// -/// # Customizing +/// # Helpers, Filters, and Customization /// /// You can use the [`Template::custom()`] method to construct a fairing with /// customized templating engines. Among other things, this method allows you to diff --git a/site/guide/responses.md b/site/guide/responses.md index 0936db17..efd3c8bd 100644 --- a/site/guide/responses.md +++ b/site/guide/responses.md @@ -257,7 +257,7 @@ a template and a context to render the template with. The context can be any type that implements `Serialize` and serializes into an `Object` value, such as structs, `HashMaps`, and others. -Rocket searches for a template with the given name in the configurable +Rocket searches for a template with the given name in the [configurable] `template_dir` directory. Templating support in Rocket is engine agnostic. The engine used to render a template depends on the template file's extension. For example, if a file ends with `.hbs`, Handlebars is used, while if a file ends @@ -281,10 +281,11 @@ fn main() { } ``` -The [`Template`] API -documentation contains more information about templates, while the [Handlebars -Templates example on +The [`Template`] API documentation contains more information about templates, +including how to customize a template engine to add custom helpers and filters. +The [Handlebars Templates example on GitHub](https://github.com/SergioBenitez/Rocket/tree/v0.4.0-dev/examples/handlebars_templates) is a fully composed application that makes use of Handlebars templates. [`Template`]: https://api.rocket.rs/rocket_contrib/struct.Template.html +[configurable]: /guide/configuration/#extras