Dotclear


Ignore:
Timestamp:
02/15/13 08:35:19 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
twig
Children:
1106:a4487f3ca4b4, 1147:2e5cb79e4782
Message:

Twig 1.12.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/libs/twig/Node/Macro.php

    r991 r1101  
    3030    public function compile(Twig_Compiler $compiler) 
    3131    { 
    32         $arguments = array(); 
    33         foreach ($this->getNode('arguments') as $argument) { 
    34             $arguments[] = '$_'.$argument->getAttribute('name').' = null'; 
     32        $compiler 
     33            ->addDebugInfo($this) 
     34            ->write(sprintf("public function get%s(", $this->getAttribute('name'))) 
     35        ; 
     36 
     37        $count = count($this->getNode('arguments')); 
     38        $pos = 0; 
     39        foreach ($this->getNode('arguments') as $name => $default) { 
     40            $compiler 
     41                ->raw('$_'.$name.' = ') 
     42                ->subcompile($default) 
     43            ; 
     44 
     45            if (++$pos < $count) { 
     46                $compiler->raw(', '); 
     47            } 
    3548        } 
    3649 
    3750        $compiler 
    38             ->addDebugInfo($this) 
    39             ->write(sprintf("public function get%s(%s)\n", $this->getAttribute('name'), implode(', ', $arguments)), "{\n") 
     51            ->raw(")\n") 
     52            ->write("{\n") 
    4053            ->indent() 
    4154        ; 
     
    4962            ; 
    5063 
    51             foreach ($this->getNode('arguments') as $argument) { 
     64            foreach ($this->getNode('arguments') as $name => $default) { 
    5265                $compiler 
    5366                    ->write('') 
    54                     ->string($argument->getAttribute('name')) 
    55                     ->raw(' => $_'.$argument->getAttribute('name')) 
     67                    ->string($name) 
     68                    ->raw(' => $_'.$name) 
    5669                    ->raw(",\n") 
    5770                ; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map