aboutsummaryrefslogtreecommitdiffstats
path: root/book/src
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2021-11-18 08:39:59 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-11-19 15:30:10 +0100
commit17af54e1129a52621393e25a1f51fe69f5896a54 (patch)
tree5277a3b930aabd157e7ca1805d7fe6989bb64a22 /book/src
parent8063e112a66d9b31f05315ccd2f8374d1c7d8d31 (diff)
downloadaskama-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.md22
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 &lt;&gt;&amp;
```
+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 &lt;&gt;&amp;
+Escape &lt;&gt;&amp;
+```
+
+[`escape = "none"`]: creating_templates.html#the-template-attribute
+
### filesizeformat
Returns adequate string representation (in KB, ..) of number of bytes: