/**
  * {@inheritdoc}
  */
 public function getSource($name)
 {
     $templates = $this->getTemplates($name);
     foreach ($templates as $template) {
         try {
             return $this->loader->getSource($template);
         } catch (\Twig_Error $e) {
         }
     }
     throw new \Twig_Error_Loader(sprintf("Template \"%s\" not found. Tried the following:\n%s", $name, implode("\n", $templates)));
 }
 public function testFindTemplateWithCache()
 {
     $basePath = dirname(__FILE__) . '/Fixtures';
     $loader = new Twig_Loader_Filesystem(array($basePath . '/normal'));
     $loader->addPath($basePath . '/named', 'named');
     // prime the cache for index.html in the named namespace
     $namedSource = $loader->getSource('@named/index.html');
     $this->assertEquals("named path\n", $namedSource);
     // get index.html from the main namespace
     $this->assertEquals("path\n", $loader->getSource('index.html'));
 }
Exemplo n.º 3
0
 public function testPaths()
 {
     $basePath = dirname(__FILE__) . '/Fixtures';
     $loader = new Twig_Loader_Filesystem(array($basePath . '/normal', $basePath . '/normal_bis'));
     $loader->setPaths(array($basePath . '/named', $basePath . '/named_bis'), 'named');
     $loader->addPath($basePath . '/named_ter', 'named');
     $loader->addPath($basePath . '/normal_ter');
     $loader->prependPath($basePath . '/normal_final');
     $loader->prependPath($basePath . '/named_final', 'named');
     $this->assertEquals(array($basePath . '/normal_final', $basePath . '/normal', $basePath . '/normal_bis', $basePath . '/normal_ter'), $loader->getPaths());
     $this->assertEquals(array($basePath . '/named_final', $basePath . '/named', $basePath . '/named_bis', $basePath . '/named_ter'), $loader->getPaths('named'));
     $this->assertEquals("path (final)\n", $loader->getSource('index.html'));
     $this->assertEquals("path (final)\n", $loader->getSource('@__main__/index.html'));
     $this->assertEquals("named path (final)\n", $loader->getSource('@named/index.html'));
 }
 public function getSource($name)
 {
     if (isset($this->templateStrings[$name])) {
         return $this->templateStrings[$name];
     }
     return parent::getSource($name);
 }
Exemplo n.º 5
0
 public function getSource($name)
 {
     if ($name == '@Theme/layout.html') {
         $Theme = \Phpfox_Template::instance()->theme()->get();
         $Service = new \Core\Theme\Service($Theme);
         return $Service->html()->get();
     }
     return parent::getSource($name);
 }
Exemplo n.º 6
0
 public function getSource($name)
 {
     if ($name == '@Theme/layout.html') {
         $Theme = \Phpfox_Template::instance()->theme()->get();
         $Service = new \Core\Theme\Service($Theme);
         return $Service->html()->get();
     } else {
         if (substr($name, 0, 7) == '@Theme/') {
             $Theme = \Phpfox_Template::instance()->theme()->get();
             $name = str_replace('@Theme/', '', $name);
             $file = $Theme->getPath() . $name;
             if (!file_exists($file)) {
                 $file = PHPFOX_DIR . 'theme/default/html/' . $name;
             }
             $html = file_get_contents($file);
             return $html;
         }
     }
     return parent::getSource($name);
 }
Exemplo n.º 7
0
 /**
  * @param string $name
  *
  * @return bool|string
  */
 public function getSource($name)
 {
     $name = $this->getName($name);
     return parent::getSource($name);
 }
Exemplo n.º 8
0
 /**
  * getSource
  *
  * @param string $name
  *
  * @return  string
  */
 public function getSource($name)
 {
     $template = parent::getSource($name);
     return $this->processor->prepareData($template);
 }
Exemplo n.º 9
0
 /**
  * Get the source of the template, without the front YAML
  *
  * @param string $name Name of the template
  *
  * @return string Source code of the template
  */
 public function getSource($name)
 {
     return $this->parser->parse(parent::getSource($name), false)->getContent();
 }
Exemplo n.º 10
0
 public function getTemplateSource($templateName)
 {
     $loader = new \Twig_Loader_Filesystem($this->getTemplateDirs());
     return $loader->getSource($templateName);
 }