aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Guillaume Gomez <guillaume1.gomez@gmail.com>2022-04-07 18:49:01 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2022-04-21 10:08:42 +0200
commit047dc82d67619c10db8fa90fad56f8c14c72782b (patch)
tree14831db678e15edfde71a782af466ac2e8f61c5e
parentadce02662016193481ff1d486cc681fe55c0019e (diff)
downloadaskama-047dc82d67619c10db8fa90fad56f8c14c72782b.tar.gz
askama-047dc82d67619c10db8fa90fad56f8c14c72782b.tar.bz2
askama-047dc82d67619c10db8fa90fad56f8c14c72782b.zip
Add documentation for suppress_whitespace
-rw-r--r--book/src/configuration.md29
1 files changed, 28 insertions, 1 deletions
diff --git a/book/src/configuration.md b/book/src/configuration.md
index 7c68724..05c18a0 100644
--- a/book/src/configuration.md
+++ b/book/src/configuration.md
@@ -11,8 +11,35 @@ This example file demonstrates the default configuration:
[general]
# Directories to search for templates, relative to the crate root.
dirs = ["templates"]
+# Unless you add a `-` in a block, whitespace won't be trimmed.
+suppress_whitespace = false
```
+In the default configuration, you can use the `-` operator to indicate that
+whitespace should be suppressed before or after a block. For example:
+
+```jinja
+<div>
+
+
+{%- if something %}
+Hello
+(% endif %}
+```
+
+In the template above, only the whitespace between `<div>` and `{%-` will be
+suppressed. If you enable `suppress_whitespace`, whitespace characters before
+and after each block will be suppressed by default. To preserve the whitespace
+characters, you can use the `+` operator:
+
+```jinja
+{% if something +%}
+Hello
+(%+ endif %}
+```
+
+In this example, `Hello` will be surrounded with newline characters.
+
Here is an example that defines two custom syntaxes:
```toml
@@ -64,4 +91,4 @@ first escaper configured and ending with the default escapers for HTML
(extensions `html`, `htm`, `xml`, `j2`, `jinja`, `jinja2`) and plain text
(no escaping; `md`, `yml`, `none`, `txt`, and the empty string). Note that
this means you can also define other escapers that match different extensions
-to the same escaper. \ No newline at end of file
+to the same escaper.