forked from zer.ooo/web
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
813 B
PHTML
41 lines
813 B
PHTML
8 years ago
|
<?php
|
||
|
/**
|
||
|
* Created by PhpStorm.
|
||
|
* User: eater
|
||
|
* Date: 4/2/16
|
||
|
* Time: 3:24 PM
|
||
|
*/
|
||
|
|
||
|
namespace Eater\Glim\Service;
|
||
|
|
||
|
|
||
|
use Eater\Glim\Core;
|
||
|
use Slim\Container;
|
||
|
|
||
|
class Twig
|
||
|
{
|
||
|
/**
|
||
|
* @param Container $c
|
||
|
* @param string $name
|
||
|
* @return \Twig_Environment
|
||
|
*/
|
||
|
static public function init($c, $name)
|
||
|
{
|
||
|
/** @var Core $core */
|
||
|
$core = $c->get('core');
|
||
|
|
||
|
$debug = $core->getConfig()->get('core.debug', false);
|
||
|
|
||
|
$loader = new \Twig_Loader_Filesystem($core->getBaseDir() . '/views/');
|
||
|
$twig = new \Twig_Environment($loader, array(
|
||
|
'cache' => $core->getBaseDir() . '/tmp/twig',
|
||
|
'debug' => $debug
|
||
|
));
|
||
|
|
||
|
if ($twig) {
|
||
|
$twig->addExtension(new \Twig_Extension_Debug());
|
||
|
}
|
||
|
|
||
|
return $twig;
|
||
|
}
|
||
|
}
|