コード例 #1
0
ファイル: kodekit.php プロジェクト: nooku/nooku-framework
 /**
  * Render a template
  *
  * @param   string  $source   A fully qualified template url or content string
  * @param   array   $data     An associative array of data to be extracted in local template scope
  * @throws \InvalidArgumentException If the template could not be located
  * @throws \RuntimeException         If a partial template url could not be fully qualified
  * @throws \RuntimeException         If the template could not be loaded
  * @throws \RuntimeException         If the template could not be compiled
  * @return string The rendered template source
  */
 public function render($source, array $data = array())
 {
     $source = parent::render($source, $data);
     //Load the template
     if ($this->getObject('filter.path')->validate($source)) {
         $source_file = $this->locateSource($source);
         if (!($cache_file = $this->isCached($source_file))) {
             $source = $this->loadSource($source_file);
             $source = $this->compileSource($source);
             $cache_file = $this->cacheSource($source_file, $source);
         }
     } else {
         $name = crc32($source);
         $source_file = '';
         if (!($cache_file = $this->isCached($name))) {
             $source = $this->compileSource($source);
             $cache_file = $this->cacheSource($name, $source);
         }
     }
     //Evaluate the template
     $result = $this->evaluateSource($cache_file);
     //Render the debug information
     $result = $this->renderDebug($result);
     return $result;
 }
コード例 #2
0
ファイル: mustache.php プロジェクト: nooku/nooku-framework
 /**
  * Render a template
  *
  * @param   string  $source   The template path or content
  * @param   array   $data     An associative array of data to be extracted in local template scope
  * @throws \RuntimeException If the template could not be loaded
  * @return string The rendered template
  */
 public function render($source, array $data = array())
 {
     parent::render($source, $data);
     //Let mustache load the template by proxiing through the load() method.
     $result = $this->_mustache->render($source, $data);
     //Render the debug information
     return $this->renderDebug($result);
 }
コード例 #3
0
ファイル: twig.php プロジェクト: nooku/nooku-framework
 /**
  * Render a template
  *
  * @param   string  $source    The template url or content
  * @param   array   $data       An associative array of data to be extracted in local template scope
  * @throws \RuntimeException If the template could not be loaded
  * @return string The rendered template source
  */
 public function render($source, array $data = array())
 {
     parent::render($source, $data);
     //Let twig load the content by proxiing through the getSource() method.
     $result = $this->_twig->render($source, $data);
     //Render the debug information
     return $this->renderDebug($result);
 }