Skip to content

Instantly share code, notes, and snippets.

@makasim
Created October 5, 2011 10:32
Show Gist options
  • Save makasim/1264135 to your computer and use it in GitHub Desktop.
Save makasim/1264135 to your computer and use it in GitHub Desktop.
Twig. How to add dir with templates
<?php
use Symfony\Component\DependencyInjection\ContainerInterface;
class Foo_Twig_Extension extends Twig_Extension
{
protected $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function initRuntime(Twig_Environment $environment)
{
$globalTemplateDir = $this->container->getParameter('kernel.root_dir') . '/views';
$environment->getLoader()->addPath($globalTemplateDir);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment