Rev | Line | |
---|
[345] | 1 | <?php |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * This file is part of Twig. |
---|
| 5 | * |
---|
| 6 | * (c) 2009 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 | class Twig_Node_Expression_Array extends Twig_Node_Expression |
---|
| 12 | { |
---|
| 13 | public function __construct(array $elements, $lineno) |
---|
| 14 | { |
---|
| 15 | parent::__construct($elements, array(), $lineno); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | /** |
---|
| 19 | * Compiles the node to PHP. |
---|
| 20 | * |
---|
| 21 | * @param Twig_Compiler A Twig_Compiler instance |
---|
| 22 | */ |
---|
| 23 | public function compile(Twig_Compiler $compiler) |
---|
| 24 | { |
---|
| 25 | $compiler->raw('array('); |
---|
| 26 | $first = true; |
---|
| 27 | foreach ($this->nodes as $name => $node) { |
---|
| 28 | if (!$first) { |
---|
| 29 | $compiler->raw(', '); |
---|
| 30 | } |
---|
| 31 | $first = false; |
---|
| 32 | |
---|
| 33 | $compiler |
---|
| 34 | ->repr($name) |
---|
| 35 | ->raw(' => ') |
---|
| 36 | ->subcompile($node) |
---|
| 37 | ; |
---|
| 38 | } |
---|
| 39 | $compiler->raw(')'); |
---|
| 40 | } |
---|
| 41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.