forked from TxHawks/edition-php-twig-development
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
27 lines (20 loc) · 855 Bytes
/
index.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
<?php
use \PatternLab\Config;
use \PatternLab\Dispatcher;
use \PatternLab\Template;
use \PatternLab\PatternEngine;
$baseDir = __DIR__ . "/";
require($baseDir . "vendor/autoload.php");
$payload = json_decode(file_get_contents("php://input"), true);
$template = (isset($payload['template'])) ? $payload['template'] : '';
$data = (isset($payload['data']) && is_array($payload['data'])) ? $payload['data'] : array();
Config::init($baseDir, $verbose = false); // So global config options are available + we can run PL w/o using the Console
Dispatcher::init(); // So plugins like Twig Namespaces work
PatternEngine::init();
Template::init();
$patternLoader = Template::getPatternLoader(); // So we don't need to worry about setting this up ourselves
$pattern = $patternLoader->render(array(
"pattern" => $template,
"data" => $data
));
print $pattern;