diff options
author | vallentin <mail@vallentin.dev> | 2021-11-18 08:39:59 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-11-19 15:30:10 +0100 |
commit | 17af54e1129a52621393e25a1f51fe69f5896a54 (patch) | |
tree | 5277a3b930aabd157e7ca1805d7fe6989bb64a22 /book/src | |
parent | 8063e112a66d9b31f05315ccd2f8374d1c7d8d31 (diff) | |
download | askama-17af54e1129a52621393e25a1f51fe69f5896a54.tar.gz askama-17af54e1129a52621393e25a1f51fe69f5896a54.tar.bz2 askama-17af54e1129a52621393e25a1f51fe69f5896a54.zip |
Updated book to include optional escaper for escape filter
Diffstat (limited to '')
-rw-r--r-- | book/src/filters.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/book/src/filters.md b/book/src/filters.md index bbeb5b8..d00d778 100644 --- a/book/src/filters.md +++ b/book/src/filters.md @@ -73,6 +73,28 @@ Output: Escape <>& ``` +Optionally, it is possible to specify and override which escaper is used. Consider a template where the escaper is configured as [`escape = "none"`]. However, somewhere escaping using the HTML escaper is desired. Then it is possible to override and use the HTML escaper like this: + +```jinja +{{ "Don't Escape <>&"|escape }} +{{ "Don't Escape <>&"|e }} + +{{ "Escape <>&"|escape("html") }} +{{ "Escape <>&"|e("html") }} +``` + +Output: + +```text +Don't Escape <>& +Don't Escape <>& + +Escape <>& +Escape <>& +``` + +[`escape = "none"`]: creating_templates.html#the-template-attribute + ### filesizeformat Returns adequate string representation (in KB, ..) of number of bytes: |