Пример #1
0
 public function render()
 {
     extract($this->variables->getVariables());
     ob_start();
     require $this->viewFile;
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
Пример #2
0
 protected function doParseLoop($var, $stack)
 {
     $working = $this->template->getVariable($var);
     if (is_null($working)) {
         return '';
     }
     if (!is_array($working) && !$working instanceof \Iterator) {
         $working = array($working);
     }
     $rtn = '';
     foreach ($working as $key => $val) {
         // Make sure we support nesting loops:
         $keyWas = $this->template->get('key');
         $valueWas = $this->template->get('value');
         $itemWas = $this->template->get('item');
         // Set up the necessary variables within the stack:
         $parent = $this->variables->getVariables();
         $this->template->set('parent', $parent);
         $this->template->set('item', $val);
         $this->template->set('key', $key);
         $this->template->set('value', $val);
         $rtn .= $this->processStack($stack);
         // Restore state for any parent nested loops:
         $this->template->set('parent', null);
         $this->template->set('item', $itemWas);
         $this->template->set('key', $keyWas);
         $this->template->set('value', $valueWas);
     }
     return $rtn;
 }