diff options
author | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-06-30 09:43:09 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-06-30 09:43:09 +0200 |
commit | 506a38e5b08deab222d25680fa7cabff02a096c5 (patch) | |
tree | 28c32b89467f80ef3d31b3e00e778b6307303c4c /book/src | |
parent | ce2d2db32ed5b4330568cdf1ce55e17242eeb334 (diff) | |
download | askama-506a38e5b08deab222d25680fa7cabff02a096c5.tar.gz askama-506a38e5b08deab222d25680fa7cabff02a096c5.tar.bz2 askama-506a38e5b08deab222d25680fa7cabff02a096c5.zip |
Move optional filter documentation into filters section
Diffstat (limited to 'book/src')
-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 |