示例#1
0
 public function render(OOTemplate_Context $context)
 {
     $result = "";
     list(, $o, , $var) = $this->_token->split();
     try {
         if (is_null($o) || is_null($var)) {
             throw new OOTemplate_Exception(sprintf("'for' statements should use the format : 'for x in y' : %s", $this->_token->contents()));
         }
         if (!$context->has_key($var)) {
             throw new OOTemplate_Exception(sprintf("'for' tag received an invalid argument : %s", $this->_token->contents()));
         }
         $current = clone $context;
         foreach ($context->get($var) as $each) {
             $current->set($o, $each->getDicts());
             foreach ($this->_nodes as $node) {
                 $result .= $node->render($current);
             }
         }
     } catch (OOTemplate_Exception $e) {
         OOTemplate_Debug::show($e->getMessage());
     }
     return $result;
 }