Changeset 1101:7273894e61b8 for inc/libs/twig/Node/Macro.php
- Timestamp:
- 02/15/13 08:35:19 (13 years ago)
- Branch:
- twig
- Children:
- 1106:a4487f3ca4b4, 1147:2e5cb79e4782
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/libs/twig/Node/Macro.php
r991 r1101 30 30 public function compile(Twig_Compiler $compiler) 31 31 { 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 } 35 48 } 36 49 37 50 $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") 40 53 ->indent() 41 54 ; … … 49 62 ; 50 63 51 foreach ($this->getNode('arguments') as $ argument) {64 foreach ($this->getNode('arguments') as $name => $default) { 52 65 $compiler 53 66 ->write('') 54 ->string($ argument->getAttribute('name'))55 ->raw(' => $_'.$ argument->getAttribute('name'))67 ->string($name) 68 ->raw(' => $_'.$name) 56 69 ->raw(",\n") 57 70 ;
Note: See TracChangeset
for help on using the changeset viewer.