Beispiel #1
0
 public function compile(Compiler $compiler, TagNode $node)
 {
     $compiler->indented('switch(')->compileNode($node->getData('tested'))->add(')')->add(' {')->indent();
     foreach ($node->getChildren() as $branch) {
         if (!$branch->hasChild('condition')) {
             $compiler->indented('default:');
         } else {
             $compiler->indented('case ')->compileNode($branch->getChild('condition'))->add(':');
         }
         $compiler->indent()->compileNode($branch->getChild('body'))->indented('break;')->outdent();
     }
     $compiler->outdent()->indented('}');
 }
Beispiel #2
0
 private function compileBlock(Compiler $compiler, $method, RootNode $body)
 {
     $compiler->indented('public function %s(Context $context)', $method);
     $compiler->indented('{');
     $compiler->indent();
     if (!$body->hasData('environment_accessed') || $body->getData('environment_accessed')) {
         $compiler->indented('$environment = $this->getEnvironment();');
     }
     $compiler->compileNode($body);
     $compiler->outdent();
     $compiler->indented("}\n");
 }