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 `&amp;`.
$subject = MergeVariables::apply($template->subject, $data, escape: false);

  $html = MergeVariables::apply($template->body, $data, raw: ['order.lines']);
  

use Goldnead\EmailTemplates\Contracts\EmailTemplateSource;

$this->app->tag([MySource::class], 'email-templates.sources');

php artisan vendor:publish --tag=email-templates-config

{{ countdown until="2026-10-01 18:00" }}
→ noch 3 Tage, 4 Stunden (01.10.2026, 18:00 Uhr)

{{ countdown_image until="2026-10-01 18:00" width="480" label="Bis zum Kursstart" }}