public function getFunctionNode($name, $line) { switch ($name) { case 'parent': $this->parseArguments(); if (!count($this->parser->getBlockStack())) { throw new Apishka_Templater_Error_Syntax('Calling "parent" outside a block is forbidden.', $line, $this->parser->getFilename()); } if (!$this->parser->getParent() && !$this->parser->hasTraits()) { throw new Apishka_Templater_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden.', $line, $this->parser->getFilename()); } return Apishka_Templater_Node_Expression_Parent::apishka($this->parser->peekBlockStack(), $line); case 'block': $args = $this->parseArguments(true, false, true); if (count($args) < 1) { throw new Apishka_Templater_Error_Syntax('The "block" function takes at least one argument (the variable and the attributes).', $line, $this->parser->getFilename()); } $block_name = $args->getNode('__first_arg__'); $args->removeNode('__first_arg__'); return Apishka_Templater_Node_Expression_BlockReference::apishka($block_name, $args, false, $line); case 'attribute': $args = $this->parseArguments(); if (count($args) < 2) { throw new Apishka_Templater_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes).', $line, $this->parser->getFilename()); } return Apishka_Templater_Node_Expression_GetAttr::apishka($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Apishka_Templater_TemplateAbstract::ANY_CALL, $line); default: return $this->getFunctionNodeDefault($name, $line); } }
public function getTests() { $tests = array(); $tests[] = array(Apishka_Templater_Node_Expression_Parent::apishka('foo', 1), '$this->renderParentBlock("foo", $context, $blocks)'); return $tests; }