-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.php
More file actions
35 lines (29 loc) · 1020 Bytes
/
build.php
File metadata and controls
35 lines (29 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Inky\Inky;
$template = file_get_contents('src/emails/welcome.inky');
// Build without data merge (template tags pass through)
$html = Inky::transformInline($template);
@mkdir('dist', 0755, true);
file_put_contents('dist/welcome.html', $html);
echo "built dist/welcome.html\n";
// Build with data merge
$data = file_get_contents('data/welcome.json');
$merged = Inky::transformWithData($template, $data);
file_put_contents('dist/welcome-merged.html', $merged);
echo "built dist/welcome-merged.html\n";
// Generate plain text
$text = Inky::toPlainText($merged);
file_put_contents('dist/welcome.txt', $text);
echo "built dist/welcome.txt\n";
// Validate
$diagnostics = Inky::validate($template);
$issues = json_decode($diagnostics, true);
if (count($issues) > 0) {
echo "\nvalidation warnings:\n";
foreach ($issues as $d) {
echo " [{$d['severity']}] {$d['rule']}: {$d['message']}\n";
}
} else {
echo "\nno validation issues found\n";
}