Evaluate email document params in template


#1

Is it possible to define conditional paragraphs in an email document template (twig), which would appear based on the value or existence of a param?

Something like:

{% if "%Text(my_var)" != "" %} ... {% endif %}

does not work unfortunately.


#2

Impossible? (except by putting all text segments in their own params of course, but this is not a good solution if you have lots of multi-language templates, for example)


#3

2018-11-05 23:00:00

bump :thinking:


#4

To do so, just pass your data as usual to your template (doesn’t matter if email or webpage).

// EmailController.php
return $this->renderTemplate('Email/template.html.twig', [
    'your' => 'params',
    // more data ...
]);