PHP code example of goldnead / statamic-email-templates
1. Go to this page and download the library: Download goldnead/statamic-email-templates library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
goldnead / statamic-email-templates example snippets
use Goldnead\EmailTemplates\Facades\EmailTemplates;
$template = EmailTemplates::resolve('welcome');
$template?->subject; // string, merge tags not yet substituted
$template?->body; // email-ready HTML
$template?->plain_text; // string|null
$template = EmailTemplates::resolve($slug, function (string $slug) {
return ['title' => '…', 'body' => '<p>…</p>']; // or null
});
use Goldnead\EmailTemplates\Support\MergeVariables;
// The body is HTML: values are escaped.
$html = MergeVariables::apply($template->body, $data);
// The subject is not HTML: ask for raw output, or the reader sees `&`.
$subject = MergeVariables::apply($template->subject, $data, escape: false);