Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@fabpot
Copy link
Member

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

I propose to removeTemplatedEmail::template() for several reasons:

  • There is no real benefit over usingtextTemplate 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 thesubject andtext block must be carefully crafted to avoid avoid HTML escaping.

Copy link
Member

@javiereguiluzjaviereguiluz left a 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.

@stof
Copy link
Member

stof commentedApr 3, 2019

👍 for me.

My current system in the Incenteev codebase looks like thistemplate way (minus theconfig block), and usage makes me wish to rewrite that to use separate templates (except I won't do it until I can migrate to symfony/mailer instead, as doing the rewrite now would be a waste of time).

@nicolas-grekasnicolas-grekas added this to thenext milestoneApr 3, 2019
@nicolas-grekas
Copy link
Member

(but see fabbot ;) )

@fabpotfabpotforce-pushed thetemplate-mime-simplification branch from1775552 to5e61b75CompareApril 3, 2019 18:46
@fabpotfabpot merged commit5e61b75 intosymfony:masterApr 3, 2019
fabpot added a commit that referenced this pull requestApr 3, 2019
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     <!-- seehttps://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/aI 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()
vincenttouzet pushed a commit to vincenttouzet/symfony that referenced this pull requestApr 3, 2019
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     <!-- seehttps://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/aI 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()
@lyrixx
Copy link
Member

lyrixx commentedApr 4, 2019
edited
Loading

  • There is no real benefit over usingtextTemplate 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...);

This is not really true about link :
<a href="XXX"> click here</a> will result inclick here without the link :/

@fabpot
Copy link
MemberAuthor

@lyrixx Not if you have Markdown installed :)

lyrixx reacted with thumbs up emoji

@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot deleted the template-mime-simplification branchMay 8, 2019 07:56
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

6 participants

@fabpot@stof@nicolas-grekas@lyrixx@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp