Skip to content
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

ENH Update code to reflect changes in template layer #1334

Merged

Conversation

GuySartorelli
Copy link
Member

Comment on lines -424 to +426
$emailData['Body'] = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields);
$engine = Injector::inst()->create(TemplateEngine::class);
$emailData['Body'] = $engine->renderString($recipient->getEmailBodyContent(), ViewLayerData::create($mergeFields));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "EmailBodyContent" is a string that represents a template. It's defined by content authors. By default it should be ss template syntax and the ss template renderer will be used - but it could be twig or whatever-the-heck else so I've decided to fetch whatever's registered under TemplateEngine instead of explicitly instantiating SSTemplateEngine here.

@@ -562,7 +568,7 @@ public function getEmailTemplateDropdownValues()
$templates = [];

$finder = new FileFinder();
$finder->setOption('name_regex', '/^.*\.ss$/');
$finder->setOption('name_regex', static::config()->get('email_template_regex'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made configurable so if someone wants to swap out to a different rendering engine they can update this to /^.*\.twig$/ or whatever.

Really this whole thing should just use the regular template/ dir and let the regular template lookup process occur - but changing that is out of scope.

@GuySartorelli GuySartorelli marked this pull request as ready for review October 23, 2024 03:00
@emteknetnz emteknetnz merged commit ea084d0 into silverstripe:7 Oct 30, 2024
8 of 11 checks passed
@emteknetnz emteknetnz deleted the pulls/7/refactor-template-layer branch October 30, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants