コード例 #1
0
ファイル: DirkTest.php プロジェクト: artoodetoo/dirk
 /**
  * @covers R2\Templating\Dirk::fetch
  */
 public function testFetch()
 {
     $parentName = $this->template('The text is `@yield(\'content\')`. ' . '@foreach([1,2,3] as $i)' . '{!! $i !!}' . '@endforeach');
     $name = $this->template("@extends('{$parentName}')-xxx-");
     $result = $this->engine->fetch($name, []);
     $this->assertEquals("The text is `-xxx-`. 123", $result);
 }
コード例 #2
0
ファイル: HamlRender.php プロジェクト: jarick/bx
 /**
  * Render
  * @param View $view
  * @param string $path
  * @param array $params
  * @return boolean
  */
 public function render($view, $path, array $params = [])
 {
     $this->fire('HamlEngineRender', [$view, $path, $params]);
     $php = $this->getPhpCacheFolder() . DIRECTORY_SEPARATOR . $path . $this->suffix_php;
     $haml = $this->getFolder() . DIRECTORY_SEPARATOR . $path . $this->suffix_haml;
     $yml = $this->getFolder() . DIRECTORY_SEPARATOR . $path . $this->suffix_yml;
     if (file_exists($yml)) {
         $meta = Yaml::parse(file_get_contents($yml));
     } else {
         $meta = [];
     }
     $path_php = false;
     $engine = $this->php_engine;
     if (file_exists($haml)) {
         if (!file_exists($php) || filemtime($php) != filemtime($haml)) {
             $this->log()->debug("render haml file `{$haml}`");
             $haml_code = file_get_contents($haml);
             $php_code = $this->haml_engine->compileString($haml_code, $haml);
             $this->filesystem()->checkPathDir(dirname($php));
             file_put_contents($php, $php_code);
             touch($haml);
         }
         $path_php = $path;
         $engine->setFolder($this->getPhpCacheFolder())->setSuffixPhp($this->suffix_php);
     } else {
         $file = $this->getFolder() . DIRECTORY_SEPARATOR . $path . $this->ext_php;
         if (file_exists($file)) {
             $path_php = $path;
             $engine->setFolder($this->getFolder())->setSuffixPhp($this->ext_php);
         }
     }
     if ($path_php) {
         $this->renderStyle($view, $path);
         $this->renderScript($view, $path);
         $this->php_engine->setMeta($meta)->render($view, $path_php, $params);
     } else {
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: TplDotPhpTest.php プロジェクト: grmule/tpldotphp
 public function testEngineNoFindTemplateWithNoInitPaths()
 {
     $nacho = new PhpEngine([]);
     $this->assertFalse($nacho->exists('poo'));
 }