# How to improve the readability of block scalars when used with jinja

**URL:** <https://forum.ansible.com/t/how-to-improve-the-readability-of-block-scalars-when-used-with-jinja/34801>\
**Category:** Ansible Project\
**Created:** [March 17, 2021, 6:56pm UTC](https://forum.ansible.com/t/how-to-improve-the-readability-of-block-scalars-when-used-with-jinja/34801 "2021-03-17T18:56:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![actionmystique](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/actionmystique/32/1678_2.png) [@actionmystique](https://forum.ansible.com/u/actionmystique)\
**Post date:** [March 17, 2021, 6:56pm UTC](https://forum.ansible.com/t/how-to-improve-the-readability-of-block-scalars-when-used-with-jinja/34801/1 "2021-03-17T18:56:38Z")

</div>

Hello everyone.  
Block scalars are described [here](https://yaml-multiline.info/).

The goal is to be improve the readability of the following block scalar example and obtain the intended value for the variable:

```auto

- set_fact:
variable: "{% if condition_1 is true %}{% if condition_2 is true %}'value'{% else %}'another value'{% endif %}{% else %}{{ another_variable }}{% endif %}"

```

I unsuccessfully tried:

```auto

- set_fact:
variable: >-
"{% if condition_1 is true %}
{% if condition_2 is true %}
'value'
{% else %}
'another value'
{% endif %}
{% else %}
{{ another_variable }}
{% endif %}"

```

Unfortunately, some spaces are added in the variable set value and there does not seem to be a way to completely “prune” them.

Am I missing something?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 17, 2021, 7:04pm UTC](https://forum.ansible.com/t/how-to-improve-the-readability-of-block-scalars-when-used-with-jinja/34801/2 "2021-03-17T19:04:47Z")

</div>

See [https://jinja.palletsprojects.com/en/master/templates/#whitespace-control](https://jinja.palletsprojects.com/en/master/templates/#whitespace-control)

---

<div class="post-metadata">

**Author:** ![actionmystique](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/actionmystique/32/1678_2.png) [@actionmystique](https://forum.ansible.com/u/actionmystique)\
**Post date:** [March 18, 2021, 12:06pm UTC](https://forum.ansible.com/t/how-to-improve-the-readability-of-block-scalars-when-used-with-jinja/34801/3 "2021-03-18T12:06:05Z")

</div>

Thanks @sivel.  
This is possible with:
