mirror of
https://github.com/twigphp/Twig.git
synced 2026-11-13 13:56:39 +00:00
42 lines
984 B
PHP
42 lines
984 B
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Twig.
|
|
*
|
|
* (c) 2009 Fabien Potencier
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
class Twig_Node_Expression_Array extends Twig_Node_Expression
|
|
{
|
|
public function __construct(array $elements, $lineno)
|
|
{
|
|
parent::__construct($elements, array(), $lineno);
|
|
}
|
|
|
|
/**
|
|
* Compiles the node to PHP.
|
|
*
|
|
* @param Twig_Compiler A Twig_Compiler instance
|
|
*/
|
|
public function compile(Twig_Compiler $compiler)
|
|
{
|
|
$compiler->raw('array(');
|
|
$first = true;
|
|
foreach (array_chunk($this->nodes, 2) as $entry) {
|
|
if (!$first) {
|
|
$compiler->raw(', ');
|
|
}
|
|
$first = false;
|
|
|
|
$compiler
|
|
->subcompile($entry[0])
|
|
->raw(' => ')
|
|
->subcompile($entry[1])
|
|
;
|
|
}
|
|
$compiler->raw(')');
|
|
}
|
|
}
|