/** * Método que parsea los nodos de la plantilla * @param \Twig_Token $token * @return AssetsNode * @throws \Twig_Error_Syntax * @throws \Twig_Error_Loader */ public function parse(\Twig_Token $token) { $hash = substr(md5($this->parser->getStream()->getSourceContext()->getPath()), 0, 8); $name = $token->getValue(); $this->extractTemplateNodes(); $node = $this->findTemplateNode(); return new AssetsNode($name, array("node" => $node, "hash" => $hash), $token->getLine(), $this->getTag(), $this->type); }
public function parse(Twig_Token $token) { $helper = $token->getValue(); $args = $this->parser->getExpressionParser()->parseArguments(); $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); $expr = new Zwig_Node_Expression_ViewHelper($helper, $args, $token->getLine(), $this->getTag()); return new Zwig_Node_Stmt($expr, array(), $token->getLine(), $this->getTag()); }
protected function isBinary(Twig_Token $token) { return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]); }
public function parse(Twig_Token $token) { $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, array('true', 'false')); return new Twig_Node_Expression_Constant('true' === $token->getValue() ? true : false, $token->getLine()); }
public function parse(Twig_Token $token) { $this->parser->getStream()->expect(Twig_Token::NUMBER_TYPE); return new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); }
/** * Parses a string attribute token, saving it as either the title, link URL, or link text * * @param \Twig_Token $token The token to parse * @param \Twig_TokenStream $stream The token stream being traversed * @return void */ protected function parseStringAttribute(\Twig_Token $token, \Twig_TokenStream $stream) { if (!$token->test(\Twig_Token::STRING_TYPE)) { throw new RuntimeException(sprintf("Expected string token but received '%s' instead", \Twig_Token::typeToEnglish($token->getType())), $stream->getCurrent()->getLine(), $stream->getFilename()); } // If any of these values has already been set, then set the next // property with this string. The string order that must be followed // in the codeblock tag is: title, url, link text if (empty($this->attributes['title'])) { $this->attributes['title'] = $token->getValue(); } elseif (empty($this->attributes['linkUrl'])) { $this->attributes['linkUrl'] = $token->getValue(); } elseif (empty($this->attributes['linkText'])) { $this->attributes['linkText'] = $token->getValue(); } }