From b9528d09c08ec4f50db80cc8d0f9c4240d6887a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Sun, 18 Apr 2021 17:09:44 +0200 Subject: [PATCH] - Add support for centering the content - Load styles from the master branch --- app/Mail/TemplateEmail.php | 2 +- app/Utils/TemplateEngine.php | 8 +++++++- resources/views/email/template/master.blade.php | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index 4c490c92e2..5aa12323bb 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -60,7 +60,7 @@ class TemplateEmail extends Mailable ); $this->build_email->setBody( - TemplateEngine::wrapElementsIntoTables('
', $this->build_email->getBody()) + TemplateEngine::wrapElementsIntoTables('
', $this->build_email->getBody()) ); $settings = $this->client->getMergedSettings(); diff --git a/app/Utils/TemplateEngine.php b/app/Utils/TemplateEngine.php index e4add15e57..858d22046d 100644 --- a/app/Utils/TemplateEngine.php +++ b/app/Utils/TemplateEngine.php @@ -259,7 +259,13 @@ class TemplateEngine $documents['wrapper'] = new \DOMDocument(); $documents['wrapper']->loadHTML($wrapper); - $styles = $documents['wrapper']->getElementsByTagName('style')->item(0)->nodeValue; + $documents['master'] = new \DOMDocument(); + + $documents['master']->loadHTML( + view('email.template.master', ['header' => '', 'slot' => ''])->render() + ); + + $styles = $documents['master']->getElementsByTagName('style')->item(0)->nodeValue; $documents['wrapper']->saveHTML(); diff --git a/resources/views/email/template/master.blade.php b/resources/views/email/template/master.blade.php index 09fc5069f0..3bd5032170 100644 --- a/resources/views/email/template/master.blade.php +++ b/resources/views/email/template/master.blade.php @@ -117,6 +117,10 @@ .button { padding: 12px; box-sizing: border-box;display: inline-block;font-family:arial,helvetica,sans-serif;text-decoration: none;-webkit-text-size-adjust: none;text-align: center;color: #FFFFFF; background-color: #142cb5; border-radius: 4px; -webkit-border-radius: 4px; -moz-border-radius: 4px; width:auto; max-width:100%; overflow-wrap: break-word; word-break: break-word; word-wrap:break-word; mso-border-alt: none; } + + .center { + text-align: center; + } @@ -199,7 +203,12 @@
+ @yield('greeting') + {{ $slot }} + + @yield('signature') + @yield('footer')