diff options
-rw-r--r-- | book/src/filters.md | 28 | ||||
-rw-r--r-- | book/src/integrations.md | 23 |
2 files changed, 26 insertions, 25 deletions
diff --git a/book/src/filters.md b/book/src/filters.md index 35cb557..6cb8566 100644 --- a/book/src/filters.md +++ b/book/src/filters.md @@ -11,7 +11,8 @@ is passed to the next. {{"HELLO" | lower}} ``` -Askama has a collection of built-in filters, documented below, but can also include custom filters. +Askama has a collection of built-in filters, documented below, but can also include custom filters. Additionally, the `json` and `yaml` filters are included in the built-in filters, +but are disabled by default. Enable them with Cargo features (see below for more information). ## Built-In Filters @@ -251,4 +252,27 @@ fn main() { let t = MyFilterTemplate { s: "foo" }; assert_eq!(t.render().unwrap(), "faa"); } -```
\ No newline at end of file +``` + +## The `json` filter + +Enabling the `serde-json` filter will enable the use of the `json` filter. +This will output formatted JSON for any value that implements the required +`Serialize` trait. + +``` +{ + "foo": "{{ foo }}", + "bar": {{ bar|json }} +} +``` + +## The `yaml` filter + +Enabling the `serde-yaml` filter will enable the use of the `yaml` filter. +This will output formatted JSON for any value that implements the required +`Serialize` trait. + +``` +{{ foo|yaml }} +``` diff --git a/book/src/integrations.md b/book/src/integrations.md index ed0fec0..25bcc18 100644 --- a/book/src/integrations.md +++ b/book/src/integrations.md @@ -50,26 +50,3 @@ Enabling the `with-warp` feature appends an implementation of Warp's `Reply` trait for each template type. This makes it simple to return a template from a Warp filter. See [the example](https://github.com/djc/askama/blob/master/askama_warp/tests/warp.rs) from the Askama test suite for more on how to integrate. - -## The `json` filter - -Enabling the `serde-json` filter will enable the use of the `json` filter. -This will output formatted JSON for any value that implements the required -`Serialize` trait. - -``` -{ - "foo": "{{ foo }}", - "bar": {{ bar|json }} -} -``` - -## The `yaml` filter - -Enabling the `serde-yaml` filter will enable the use of the `yaml` filter. -This will output formatted JSON for any value that implements the required -`Serialize` trait. - -``` -{{ foo|yaml }} -```
\ No newline at end of file |