Exemplo n.º 1
0
 /**
  * Renders the current template
  *
  * @param array $assigns An array of values for the template
  * @param array $filters Additional filters for the template
  * @param array $registers Additional registers for the template
  * @return string
  */
 function render($assigns = null, $filters = null, $registers = null)
 {
     if (is_null($assigns)) {
         $assigns = array();
     }
     $context = new LiquidContext($assigns, $registers);
     if (!is_null($filters)) {
         if (is_array($filters)) {
             array_merge($this->filters, $filters);
         } else {
             $this->filters[] = $filters;
         }
     }
     foreach ($this->filters as $filter) {
         $context->add_filters($filter);
     }
     return $this->root->render($context);
 }
Exemplo n.º 2
0
 /**
  * Renders the node
  *
  * @param LiquidContext $context
  */
 function render(&$context)
 {
     $result = '';
     $variable = $context->get($this->variable);
     $context->push();
     foreach ($this->attributes as $key => $value) {
         $context->set($key, $context->get($value));
     }
     if ($this->collection) {
         foreach ($variable as $item) {
             $context->set($this->template_name, $item);
             $result .= $this->document->render($context);
         }
     } else {
         if (!is_null($this->variable)) {
             $context->set($this->template_name, $variable);
         }
         $result .= $this->document->render($context);
     }
     $context->pop();
     return $result;
 }