From 17af54e1129a52621393e25a1f51fe69f5896a54 Mon Sep 17 00:00:00 2001 From: vallentin Date: Thu, 18 Nov 2021 08:39:59 +0100 Subject: Updated book to include optional escaper for escape filter --- book/src/filters.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'book/src') 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: -- cgit