aboutsummaryrefslogtreecommitdiffstats
path: root/book
diff options
context:
space:
mode:
Diffstat (limited to '')
-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.