protected function createRenderer()
{
$config = $this->container['app.config'];
$loader = new \Twig_Loader_Filesystem($this->app->getTemplateDir());
$twig = new \Twig_Environment($loader, ['debug' => $config->get('debug', false), 'cache' => $config->get('twig.cache', false), 'charset' => $config->get('twig.charset', 'utf-8')]);
// add built-in template path
$loader->addPath(__DIR__ . '/template/error');
// add built-in extension
$twig->addExtension((new DietcubeExtension())->setContainer($this->container));
if ($this->app->isDebug()) {
// add built-in debug template path
$twig->addExtension(new \Twig_Extension_Debug());
$loader->addPath(__DIR__ . '/template/debug', 'debug');
}
$twig->addGlobal('query', $this->container['global.get']->getData());
$twig->addGlobal('body', $this->container['global.post']->getData());
return $twig;
}