Closed
Description
Description
The Symfony\Bridge\Twig\Mime\TemplatedEmail
currently only allows a string a param which contains the path to the twig template.
The Symfony\Bridge\Twig\Mime\TemplatedEmail
should additional allow Twig\TemplateWrapper
for the methods:
htmlTemplate()
textTemplate()
The BodyRenderer uses internally $this->twig->render()
. This method allows the usage of string and TemplateWrapper as param.
As result also inline twig templates could be used. This is helpful if the template content should be modified before applying a twig rendering.
Example
$twig = new Environment(new ArrayLoader(['testTemplate' => 'Twig content']));
$twigTemplate = $twig->load('testTemplate');
$email = (new TemplatedEmail())
->from(new Address('me@example.com'))
->to(new Address('someone@example.com'))
->subject('E-Mail Subject')
->htmlTemplate($twigTemplate);