Skip to main content

Tool: use conditions in templates!

WritingYou can resort to programming in progress...your ↁ_ↁtemplates. The configuration is a bit technical, but will result in:

  • modulable texts
  • cleaner interfaces
  • less technical support

In a few words, Nestor uses a bit of magic to generate text in messages. You can harness this to modify texts on the fly, by using branching conditions in your templates: https://twig.symfony.com/doc/2.x/tags/index.html

AnyThe enquiries?description pleasebelow contactgives us: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
  • but when conditions are met, modify a few parts of the text

We could create two different templates:

Template of acceptance for a "regular article"
Template of acceptance for a "note to the editor"

Dear author,

 

Congratulations on being accepted! We have received all source files and your paper is now in the hands of the copy editor.

 

You will receive the galley proofs in about two weeks.

 

Best regards,

The Editorial Office

Dear author,


Congratulations on being accepted! We have received all source files and your note to the editor is about to be published!


You will receive the galley proofs by tomorrow.


Best regards,

The Editorial Office

This presents the following downsides:

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

support@nestor-edp.orgimage.png

 


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

Global template of acceptance

Dear author,

 

Congratulations on being accepted! We have received all source files and your {% 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 %}.

 

You will receive the galley proofs in about {% if article.articleType.code == 'REGULAR' %}two weeks{% else %}by tomorrow{% endif %}.

 

Best regards,
The Editorial Office

This results in a single template to maintain, and a cleaner editor interface. Life is noticeably better:

image.png