-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Twig] Remove TemplatedEmail::template() #30853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
While documenting the Mime component (pending PR here: symfony/symfony-docs#11280) I also found a bit confusing to have multiple ways of doing the same thing.
Also, using pure Twig code to define all email parts (such as the priority, subject, from, to, etc.) looks appealing at first but it generates complex and not very readable code in real-world applications. Better use PHP to create the message and (optionally) Twig to render its contents.
👍 for me. My current system in the Incenteev codebase looks like this |
(but see fabbot ;) ) |
1775552
to
5e61b75
Compare
This PR was merged into the 4.3-dev branch. Discussion ---------- [Twig] Remove TemplatedEmail::template() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | n/a I propose to remove `TemplatedEmail::template()` for several reasons: * There is no real benefit over using `textTemplate` and `htmlTemplate` (ok, you only have one template instead of two... but the text template can only be automatically created based on the HTML one, so...); * It means having more than one way to do the same thing (do I set the subject on the object directly or in the template for instance); * A major drawback that is not easy to spot: the template is HTML, so the `subject` and `text` block must be carefully crafted to avoid avoid HTML escaping. Commits ------- 5e61b75 [Twig] removed TemplatedEmail::template()
This PR was merged into the 4.3-dev branch. Discussion ---------- [Twig] Remove TemplatedEmail::template() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | n/a I propose to remove `TemplatedEmail::template()` for several reasons: * There is no real benefit over using `textTemplate` and `htmlTemplate` (ok, you only have one template instead of two... but the text template can only be automatically created based on the HTML one, so...); * It means having more than one way to do the same thing (do I set the subject on the object directly or in the template for instance); * A major drawback that is not easy to spot: the template is HTML, so the `subject` and `text` block must be carefully crafted to avoid avoid HTML escaping. Commits ------- 5e61b75 [Twig] removed TemplatedEmail::template()
This is not really true about link : |
@lyrixx Not if you have Markdown installed :) |
I propose to remove
TemplatedEmail::template()
for several reasons:There is no real benefit over using
textTemplate
andhtmlTemplate
(ok, you only have one template instead of two... but the text template can only be automatically created based on the HTML one, so...);It means having more than one way to do the same thing (do I set the subject on the object directly or in the template for instance);
A major drawback that is not easy to spot: the template is HTML, so the
subject
andtext
block must be carefully crafted to avoid avoid HTML escaping.