PEEL Shopping
Open source ecommerce : PEEL Shopping
Use.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) 2011 Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
27 {
35  public function parse(Twig_Token $token)
36  {
37  $template = $this->parser->getExpressionParser()->parseExpression();
38  $stream = $this->parser->getStream();
39 
40  if (!$template instanceof Twig_Node_Expression_Constant) {
41  throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getFilename());
42  }
43 
44  $targets = array();
45  if ($stream->test('with')) {
46  $stream->next();
47 
48  do {
49  $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
50 
51  $alias = $name;
52  if ($stream->test('as')) {
53  $stream->next();
54 
55  $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
56  }
57 
58  $targets[$name] = new Twig_Node_Expression_Constant($alias, -1);
59 
60  if (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ',')) {
61  break;
62  }
63 
64  $stream->next();
65  } while (true);
66  }
67 
68  $stream->expect(Twig_Token::BLOCK_END_TYPE);
69 
70  $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
71  }
72 
78  public function getTag()
79  {
80  return 'use';
81  }
82 }
Base class for all token parsers.
Definition: TokenParser.php:17
getTag()
Gets the tag name associated with this token parser.
Definition: Use.php:78
Represents a node in the AST.
Definition: Node.php:18
Exception thrown when a syntax error occurs during lexing or parsing of a template.
Definition: Syntax.php:18
parse(Twig_Token $token)
Parses a token and returns a node.
Definition: Use.php:35
const BLOCK_END_TYPE
Definition: Token.php:28
Represents a Token.
Definition: Token.php:18
const NAME_TYPE
Definition: Token.php:30
const PUNCTUATION_TYPE
Definition: Token.php:34
Imports blocks defined in another template into the current template.
Definition: Use.php:26

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:19 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.