# Drafting templates with conditions!

Nestor uses a [programming language](https://twig.symfony.com/) to generate text in messages. You can harness this and use branching conditions in your templates: [https://twig.symfony.com/doc/2.x/tags/index.html](https://twig.symfony.com/doc/2.x/tags/index.html). The configuration is a bit technical, but will result in:

- modulable texts
- cleaner interfaces
- less technical support

The description below gives one typical example, but the possibilities are endless.

---

#### E-mail conditions: a case study

Let us consider the case of the acceptance letter, where we want to:

- use some general text to inform the author that the article is accepted
- IF certain conditions are met, modify a few parts of the text

For this purpose, we could create two different templates:

<table border="1" id="bkmrk-template-of-acceptan" style="border-collapse: collapse; width: 100%; height: 266.8px;"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr style="height: 29.8px;"><td style="height: 29.8px;">**Template for a "regular article"**  
</td><td style="height: 29.8px;">**Template for a "note to the editor"**  
</td></tr><tr style="height: 237px;"><td style="height: 237px;">Dear author,

Congratulations on being accepted! We have received all source files and your <span style="color: rgb(224, 62, 45);">paper is now in the hands of the copy editor.</span>

You will receive the galley proofs in about <span style="color: rgb(224, 62, 45);">two weeks</span>.

Best regards,

The Editorial Office

</td><td style="height: 237px;">Dear author,

Congratulations on being accepted! We have received all source files and your <span style="color: rgb(224, 62, 45);">note to the editor is about to be published!</span>

You will receive the galley proofs <span style="color: rgb(224, 62, 45);">by tomorrow</span>.

Best regards,

The Editorial Office

</td></tr></tbody></table>

This presents the following downsides:

- now we have two similar templates to maintain
- this clutters the editor interface:

<table border="1" id="bkmrk--0" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.8765%;"></col></colgroup><tbody><tr><td>[![image.png](https://doc.nestor-edp.org/uploads/images/gallery/2023-05/scaled-1680-/z2BUVu6ctrcjXy6Q-image.png)](https://doc.nestor-edp.org/uploads/images/gallery/2023-05/z2BUVu6ctrcjXy6Q-image.png)

</td></tr></tbody></table>

---

Instead, let us create one single template, inserting cool conditions when needed:

<table border="1" id="bkmrk-global-template-of-a" style="border-collapse: collapse; width: 100%;"><tbody><tr><td>**Global template**  
</td></tr><tr><td>Dear author,

Congratulations on being accepted! We have received all source files and your <span style="color: rgb(224, 62, 45);">{% if article.articleType.code == 'REGULAR' %}paper is now in the hands of the copy editor{% else %}note to the editor is about to be published!{% endif %}</span>.

You will receive the galley proofs in about <span style="color: rgb(224, 62, 45);">{% if article.articleType.code == 'REGULAR' %}two weeks{% else %}by tomorrow{% endif %}.</span>

Best regards,  
The Editorial Office

</td></tr></tbody></table>

This results in a single template to maintain, and a cleaner editor interface:

[![image.png](https://doc.nestor-edp.org/uploads/images/gallery/2023-05/scaled-1680-/CH6Gc0xjAMsYisV7-image.png)](https://doc.nestor-edp.org/uploads/images/gallery/2023-05/CH6Gc0xjAMsYisV7-image.png)