-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplates.php
28 lines (22 loc) · 940 Bytes
/
templates.php
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
<?php
require_once(__DIR__ . '/Handlebars/Autoloader.php');
Handlebars\Autoloader::register();
use Handlebars\Handlebars;
use Handlebars\Loader\FilesystemLoader;
# Set the partials files
$partialsDir = __DIR__ . '/templates';
$partialsLoader = new FilesystemLoader($partialsDir, [
"extension" => "hbs"
]);
$handlebars = new Handlebars([
"loader" => $partialsLoader,
"partials_loader" => $partialsLoader
]);
$handlebars->addHelper("safe", function ($template, $context, $args, $source) {
return $context->get($args);
});
$handlebars->addHelper('random_emoji', function ($template, $context, $args, $source) {
$emojis = [ 'smile-wink', 'smile-beam', 'smile', 'grin-beam-sweat', 'grin-squint-tears', 'grin-squint', 'grin-hearts', 'grin-beam', 'grin-alt', 'grin', 'grin-wink' ];
return $emojis[rand(0, count($emojis) - 1)];
});
?>