Skip to content

Commit

Permalink
Add documentation for automatic_block_trim
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 11, 2022
1 parent 6901c38 commit 79747c3
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,37 @@ 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.
automatic_trim_block = false
```

About `automatic_trim_block`, if you want to trim whitespace before or after a
block, you need to use the minus sign. For example:

```jinja
<div>
{%- if something %}
Hello
(% endif %}
```

In this case, only the content between `<div>` and `{%-` will be trimmed. If
this option is enabled, all content before and after each jinja block will be
trimmed.

If the option is enabled but you don't want a part to be trimmed, use the plus
(`+`) sign:

```jinja
{% if something +%}
Hello
(%+ endif %}
```

In this example, `Hello` will be surrounded with backlines.

Here is an example that defines two custom syntaxes:

```toml
Expand Down Expand Up @@ -64,4 +93,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.
to the same escaper.

0 comments on commit 79747c3

Please sign in to comment.