-
Notifications
You must be signed in to change notification settings - Fork 226
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
ENH Update code to reflect changes in template layer #1334
Conversation
80112d7
to
dc84a23
Compare
dc84a23
to
06cd3ee
Compare
06cd3ee
to
5e315a1
Compare
$emailData['Body'] = SSViewer::execute_string($recipient->getEmailBodyContent(), $mergeFields); | ||
$engine = Injector::inst()->create(TemplateEngine::class); | ||
$emailData['Body'] = $engine->renderString($recipient->getEmailBodyContent(), ViewLayerData::create($mergeFields)); |
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.
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')); |
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.
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.
Relies and reflects on changes in silverstripe/silverstripe-framework#11405
Issue