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

View File

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

View File

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

View File

@ -126,6 +126,7 @@ class TemplateEngine
]);
$this->body = $converter->convertToHtml($this->body);
}
private function entityValues($contact)
@ -165,10 +166,12 @@ class TemplateEngine
$wrapper = '';
}
} else {
$wrapper = $this->getTemplate();
$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 = [
'subject' => $this->subject,
'body' => $this->body,

View File

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

View File

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

View File

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