protected function getLoader()
    {
        $config = $this->getConfig();
        $chain = new \Twig_Loader_Chain();

        // use template's own directory to search for templates
        $paths = array($config['phr_template_dir']);

        // inject common paths
        $projectPath = new ProjectPath($config['phr_template_dir']);
        if ($projectPath = $projectPath->get()) {
            $paths[] = $projectPath . DIRECTORY_SEPARATOR . 'layouts';
            $paths[] = $projectPath;
        }
        $chain->addLoader(new \Twig_Loader_Filesystem($paths));

        // add string template loader, which is responsible for loading templates
        // and removing front-matter
        $chain->addLoader(new \Phrozn\Twig\Loader\String);

        return $chain;
    }