Skip to content

Symfony\Bridge\Twig\Mime\TemplatedEmail should allow TemplateWrapper as html and text template #41126

Closed
@sven-communitales

Description

@sven-communitales

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);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions