Example #1
0
 /**
  * Render the template
  * Uses the final view/template returned from the `Lexer::$_blockSet`
  * @param  string $template full path to template file
  * @param  array  $data     data vars
  * @param  array  $options
  * 
  * @uses Lexer::$_blockSet `BlockSet` returned from templates
  * 
  * @return string           parsed template with block sections replaced
  */
 public function render($template, $data = array(), array $options = array())
 {
     $defaults = array('context' => array(), 'type' => 'html');
     $options += $defaults;
     $this->_context = $options['context'] + $this->_context;
     $this->_data = (array) $data + $this->_vars;
     $template__ = $template;
     // Load pages/layouts
     if (!preg_match("/element/", $template__)) {
         $cache = new Cache();
         // Get all the template blocks
         static::$_blocks = Lexer::run($template__, $data, $options);
         if (gettype(static::$_blocks) == 'object') {
             // parse the template contents, master is the final template
             $cacheFile = Parser::parse(static::$_blocks, $data, $options);
         } else {
             $cacheFile = static::$_blocks;
         }
         $template__ = $cacheFile;
     }
     unset($options, $template, $defaults, $data);
     if ($this->_config['extract']) {
         extract($this->_data, EXTR_OVERWRITE);
     } elseif ($this->_view) {
         extract((array) $this->_view->outputFilters, EXTR_OVERWRITE);
     }
     ob_start();
     include $template__;
     return ob_get_clean();
 }