本文整理汇总了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;
}