i try to render an email template as a virtual page (preview of mail).
is there a way i can pass the data to the template like in $kirby->email() ?
'pattern' => 'preview-mail',
'action' => function () {
return new Page([
'slug' => 'virtual-email',
'template' => 'emails/default',
'content' => [
'headline' => 'This is not a real mail',
'text' => 'Believe it or not, this mail is not real'
],
]);
}
does not work. I replaced ‘content’ with 'data with the same result.
Ok, and now I see that email templates would expect them as variables e.g. <?= $headline ?> while as virtual page you’ll get those values as <?= $page->headline ?>
So you could indeed try a controller as suggested by @ahmetbora.
Or in your templates you write fallbacks, so it works for both use cases