示例#1
0
 /**
  * Compile the current node to text
  *
  * @return string
  */
 public function compile()
 {
     $buffer = 'foreach (' . $this->compileChild($this->node->getCollection()) . ' as ';
     // if we have a key
     if ($keyVar = $this->node->getKeyVariable()) {
         $buffer .= $this->compileChild($keyVar) . ' => ';
     }
     // and the value variable
     $buffer .= $this->compileChild($this->node->getValueVariable()) . ") {\n";
     // compile child scope
     $buffer .= parent::compile();
     // close the loop scope
     $buffer .= "\n}";
     return $buffer;
 }
示例#2
0
 /**
  * Compile tattoo scope to php
  *
  * @throws Tattoo\Exception
  *
  * @param Node\Scope            $code
  * @return array
  */
 public function compile(ScopeNode $scope)
 {
     $compiler = new ScopeCompiler($scope, $this->configuration['compiler']);
     return $compiler->compile();
 }