ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SimpleTokenParser.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) 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
13{
14 protected $tag;
15 protected $grammar;
16
17 public function __construct($tag, $grammar)
18 {
19 $this->tag = $tag;
20 $this->grammar = $grammar;
21 }
22
23 public function getGrammar()
24 {
25 return $this->grammar;
26 }
27
28 public function getTag()
29 {
30 return $this->tag;
31 }
32
33 public function getNode(array $values, $line)
34 {
35 $nodes = array();
36 $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Constant('|', $line), $line);
37 foreach ($values as $value) {
38 if ($value instanceof Twig_Node) {
39 if ($value instanceof Twig_Node_Expression_Array) {
40 $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Function('dump', $value, $line), $line);
41 } else {
42 $nodes[] = new Twig_Node_Print($value, $line);
43 }
44 } else {
45 $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Constant($value, $line), $line);
46 }
47 $nodes[] = new Twig_Node_Print(new Twig_Node_Expression_Constant('|', $line), $line);
48 }
49
50 return new Twig_Node($nodes);
51 }
52}
An exception for terminatinating execution or to throw for unit testing.
getNode(array $values, $line)
Gets the nodes based on the parsed values.
__construct($tag, $grammar)
getGrammar()
Gets the grammar as an object or as a string.
getTag()
Gets the tag name associated with this token parser.
Represents a node that outputs an expression.
Definition: Print.php:19
Represents a node in the AST.
Definition: Node.php:19
$values