Fixes for email templates not displaying css correctly

This commit is contained in:
David Bomba 2020-08-02 19:59:32 +10:00
parent 6ca8bb95bd
commit 81a34f3446
8 changed files with 25 additions and 11 deletions

View File

@ -119,7 +119,9 @@ class EmailTemplateDefaults
'allow_unsafe_links' => false, 'allow_unsafe_links' => false,
]); ]);
return $converter->convertToHtml(self::transformText('invoice_message')); $invoice_message = '<p>' . self::transformText('invoice_message') . '</p><br><br><p>$view_link</p>';
return $invoice_message;
//return $converter->convertToHtml($invoice_message);
} }

View File

@ -16,6 +16,7 @@ use App\Utils\TemplateEngine;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesInvoiceHtml; use App\Utils\Traits\MakesInvoiceHtml;
use App\Utils\Traits\MakesTemplateData; use App\Utils\Traits\MakesTemplateData;
use Illuminate\Notifications\Messages\MailMessage;
use League\CommonMark\CommonMarkConverter; use League\CommonMark\CommonMarkConverter;
class TemplateController extends BaseController class TemplateController extends BaseController
@ -93,6 +94,8 @@ class TemplateController extends BaseController
$data = (new TemplateEngine($body, $subject, $entity, $entity_id, $template))->build(); $data = (new TemplateEngine($body, $subject, $entity, $entity_id, $template))->build();
return response()->json($data, 200); return response()->json($data, 200);
} }
} }

View File

@ -131,6 +131,12 @@ class BaseNotification extends Notification implements ShouldQueue
case 'custom': case 'custom':
return 'email.template.custom'; return 'email.template.custom';
break; break;
case 'light':
return 'email.template.light';
break;
case 'dark':
return 'email.template.dark';
break;
default: default:
return 'email.admin.generic_email'; return 'email.admin.generic_email';
break; break;

View File

@ -77,8 +77,8 @@ class SendGenericNotification extends BaseNotification implements ShouldQueue
$mail_message = (new MailMessage) $mail_message = (new MailMessage)
->withSwiftMessage(function ($message) { ->withSwiftMessage(function ($message) {
$message->getHeaders()->addTextHeader('Tag', $this->invitation->company->company_key); $message->getHeaders()->addTextHeader('Tag', $this->invitation->company->company_key);
//})->markdown($this->getTemplateView(), $this->buildMailMessageData()); })->markdown($this->getTemplateView(), $this->buildMailMessageData());
})->markdown('email.template.plain', $this->buildMailMessageData()); //})->markdown('email.template.plain', $this->buildMailMessageData());
$mail_message = $this->buildMailMessageSettings($mail_message); $mail_message = $this->buildMailMessageSettings($mail_message);

View File

@ -126,6 +126,7 @@ class TemplateEngine
]); ]);
$this->body = $converter->convertToHtml($this->body); $this->body = $converter->convertToHtml($this->body);
} }
private function entityValues($contact) private function entityValues($contact)
@ -165,10 +166,12 @@ class TemplateEngine
$wrapper = ''; $wrapper = '';
} }
} else { } else {
$wrapper = $this->getTemplate();
$wrapper = view($this->getTemplatePath($email_style), $data)->render(); $wrapper = view($this->getTemplatePath($email_style), $data)->render();
$injection = '<head><link rel="stylesheet" type="text/css" property="stylesheet" href="'.config('ninja.app_url').'/css/tailwind-1.2.0.css">';
$wrapper = str_replace('<head>',$injection ,$wrapper);
} }
info($this->body);
$data = [ $data = [
'subject' => $this->subject, 'subject' => $this->subject,
'body' => $this->body, 'body' => $this->body,

View File

@ -9,6 +9,6 @@
{{ $slot }} {{ $slot }}
</h1> </h1>
@isset($p) @isset($p)
<p>{{ $p }}</p> {!! $p !!}
@endisset @endisset
</div> </div>

View File

@ -26,13 +26,13 @@
{{ $header }} {{ $header }}
<div id="text" class="px-10 py-6 flex flex-col"> <div id="text" class="px-10 py-6 flex flex-col">
@isset($greeting) @isset($greeting)
<p>{{ $greeting }}</p> {{ $greeting }}
@endisset @endisset
<p>
{{ $slot }} {{ $slot }}
</p>
@isset($signature) @isset($signature)
<p>{{ $signature }}</p> {{ $signature }}
@endisset @endisset
</div> </div>
</div> </div>

View File

@ -1,9 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ App::getLocale() }}"> <html lang="{{ App::getLocale() }}" class="bg-white">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
</head> </head>
<body> <body class="bg-white">
{!! $body !!} {!! $body !!}
</body> </body>
<footer> <footer>