diff options
author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2022-04-21 16:50:56 +0200 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2022-04-26 10:15:34 +0200 |
commit | f997ba97bd298e219f3286fa792ec10874a34079 (patch) | |
tree | 8e03169c6cfa53b6867c01fdb94b406e3fcb2f94 /book | |
parent | 1119be008a540e0759b6de95f4a1720855a809d4 (diff) | |
download | askama-f997ba97bd298e219f3286fa792ec10874a34079.tar.gz askama-f997ba97bd298e219f3286fa792ec10874a34079.tar.bz2 askama-f997ba97bd298e219f3286fa792ec10874a34079.zip |
Add documentation for `~` and `"minimize"`
Diffstat (limited to 'book')
-rw-r--r-- | book/src/configuration.md | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/book/src/configuration.md b/book/src/configuration.md index acc9751..abf276d 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -11,7 +11,7 @@ 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. +# Unless you add a `-` in a block, whitespace characters won't be trimmed. whitespace = "preserve" ``` @@ -24,7 +24,7 @@ whitespace should be suppressed before or after a block. For example: {%- if something %} Hello -(% endif %} +{% endif %} ``` In the template above, only the whitespace between `<div>` and `{%-` will be @@ -35,11 +35,26 @@ characters, you can use the `+` operator: ```jinja {% if something +%} Hello -(%+ endif %} +{%+ endif %} ``` In this example, `Hello` will be surrounded with newline characters. +There is a third possibility: in case you want to suppress all whitespace +characters except one, you can use `~`: + +```jinja +{% if something ~%} +Hello +{%~ endif %} +``` + +To be noted, if one of the trimmed characters is a newline, then the only +character remaining will be a newline. + +If you want this to be the default behaviour, you can set `whitespace` to +`"minimize"`. + Here is an example that defines two custom syntaxes: ```toml |