本文整理匯總了PHP中Twig_Parser::getExpressionParser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Twig_Parser::getExpressionParser方法的具體用法?PHP Twig_Parser::getExpressionParser怎麽用?PHP Twig_Parser::getExpressionParser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Twig_Parser
的用法示例。
在下文中一共展示了Twig_Parser::getExpressionParser方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parseTestExpression
public function parseTestExpression(Twig_Parser $parser, $node)
{
$stream = $parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE);
$arguments = null;
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
$arguments = $parser->getExpressionParser()->parseArguments();
}
return new Twig_Node_Expression_Test($node, $name->getValue(), $arguments, $parser->getCurrentToken()->getLine());
}
示例2: parseTestExpression
public function parseTestExpression(Twig_Parser $parser, $node)
{
$stream = $parser->getStream();
$name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
$arguments = null;
if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
$arguments = $parser->getExpressionParser()->parseArguments();
}
$class = $this->getTestNodeClass($parser->getEnvironment(), $name);
return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
}
示例3: parseOptionsTag
public function parseOptionsTag(\Twig_Parser $parser, $hasContent = true, $method = 'decideBlockEnd')
{
$options = array();
if (!$parser->getStream()->test(\Twig_Token::BLOCK_END_TYPE)) {
do {
$nameExpression = $this->parser->getExpressionParser()->parseExpression();
$name = $nameExpression->getAttribute('name');
$options['names'][$name] = $nameExpression;
$parser->getStream()->expect(\Twig_Token::OPERATOR_TYPE, '=');
$options['values'][$name] = $parser->getExpressionParser()->parseExpression();
} while (!$parser->getStream()->test(\Twig_Token::BLOCK_END_TYPE));
}
if ($hasContent) {
$parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
$options['content'] = $parser->subparse(array($this, $method), true);
}
$parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
return $options;
}