예제 #1
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('<?php elseif( ');
     foreach ($this->getAttributes() as $a) {
         $a->compile($compiler);
     }
     $compiler->write(' ): ?>');
 }
예제 #2
0
 public function compile(CompilerInterface $compiler, $local = false)
 {
     if ($local) {
         $compiler->write('$' . str_replace('.', '->', $this->name));
     } else {
         $compiler->write('$env->' . str_replace('.', '->', $this->name));
     }
 }
예제 #3
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('<?php echo htmlspecialchars(');
     foreach ($this->getChildren() as $c) {
         $c->compile($compiler);
     }
     $compiler->write('); ?>');
 }
예제 #4
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('<?php $tpl->render(');
     foreach ($this->getAttributes() as $a) {
         $a->compile($compiler);
     }
     $compiler->write('); ?>');
 }
예제 #5
0
 public function compile(CompilerInterface $compiler)
 {
     if ($this->type === '+') {
         $compiler->write(' . ');
     } else {
         $compiler->write(' ' . $this->type . ' ');
     }
 }
예제 #6
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('[');
     foreach ($this->getChildren() as $c) {
         $c->compile($compiler);
     }
     $compiler->write(']');
 }
예제 #7
0
 public function compile(CompilerInterface $compiler)
 {
     if ($this->type === 'not') {
         $compiler->write(' ! ');
     } elseif ($this->type === 'or') {
         $compiler->write(' || ');
     } elseif ($this->type === 'and') {
         $compiler->write(' && ');
     } elseif ($this->type === 'equals') {
         $compiler->write(' === ');
     }
 }
예제 #8
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('<?php if( ');
     foreach ($this->getAttributes() as $a) {
         $a->compile($compiler);
     }
     $compiler->write(' ): ?>');
     foreach ($this->getChildren() as $c) {
         $c->compile($compiler);
     }
     $compiler->write('<?php endif; ?>');
 }
예제 #9
0
 public function compile(CompilerInterface $compiler)
 {
     $loopitem = $this->getAttribute(0);
     $arrayable = $this->getAttribute(1);
     if ($loopitem instanceof VariableNode) {
         $compiler->write('<?php foreach(');
         $arrayable->compile($compiler);
         $compiler->write(' as ');
         $loopitem->compile($compiler);
         $compiler->write('): ?>');
         foreach ($this->getChildren() as $c) {
             $c->compile($compiler);
         }
         $compiler->write('<?php endforeach; ?>');
         $compiler->write('<?php unset(');
         $loopitem->compile($compiler);
         $compiler->write('); ?>');
     } elseif ($loopitem instanceof NumberNode) {
         $loopvar = null;
         if ($this->getAttribute(2)) {
             $loopvar = $this->getAttribute(2);
         }
         $compiler->write('<?php for( ');
         $compiler->write('$i');
         $compiler->write(' = ');
         $loopitem->compile($compiler);
         $compiler->write('; ');
         $compiler->write('$i');
         $compiler->write(' <= ');
         $arrayable->compile($compiler);
         $compiler->write('; ');
         $compiler->write('$i');
         $compiler->write('++ ): ?>');
         if ($loopvar !== null) {
             $compiler->write('<?php $env->set( \'' . $loopvar->getName() . '\', $i ); ?>');
         }
         foreach ($this->getChildren() as $c) {
             $c->compile($compiler);
         }
         $compiler->write('<?php endfor; ?>');
     }
 }
예제 #10
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('$env->functions[');
     $compiler->write('\'');
     $compiler->write($this->funcName);
     $compiler->write('\'');
     $compiler->write(']');
     $compiler->write('(');
     foreach ($this->getChildren() as $c) {
         $c->compile($compiler);
     }
     $compiler->write(')');
 }
예제 #11
0
 public function compile(CompilerInterface $compiler)
 {
     $nameAttr = $this->getAttribute(0);
     $subcompiler = new Compiler($nameAttr);
     $name = $subcompiler->compile();
     // Determine which function to use
     $blockHeadFunction = 'setBlock';
     if ($this->getAttribute(1)) {
         $optionAttr = $this->getAttribute(1);
         if ($optionAttr->getValue() === 'prepend') {
             $blockHeadFunction = 'prependBlock';
         } elseif ($optionAttr->getValue() === 'append') {
             $blockHeadFunction = 'appendBlock';
         }
     }
     // Write the heads of the children first
     foreach ($this->getChildren() as $c) {
         $subcompiler = new Compiler($c);
         $subcompiler->compile();
         $compiler->head($subcompiler->getHead());
     }
     // Write head of itself
     $compiler->head('<?php $env->' . $blockHeadFunction . '( ');
     $compiler->head($name);
     $compiler->head(', function() use ( $env, $tpl ) { ?>');
     foreach ($this->getChildren() as $c) {
         $subcompiler = new Compiler($c);
         $subcompiler->compile();
         $compiler->head($subcompiler->getBody());
     }
     $compiler->head('<?php } ); ?>');
     // Render itself
     $compiler->write('<?php $env->getBlock( ');
     $compiler->write($name);
     $compiler->write('); ?>');
 }
예제 #12
0
 public function compile(CompilerInterface $compiler)
 {
     // Render the head of the extended template
     $compiler->head('<?=$tpl->renderHead( ');
     foreach ($this->getAttributes() as $a) {
         $subcompiler = new Compiler($a);
         $compiler->head($subcompiler->compile());
     }
     $compiler->head(')?>');
     // Write the head of the current template
     foreach ($this->getChildren() as $c) {
         $subcompiler = new Compiler($c);
         $subcompiler->compile();
         $compiler->head($subcompiler->getHead());
     }
     // Render the body of the extended template
     $compiler->write('<?=$tpl->renderBody( ');
     foreach ($this->getAttributes() as $a) {
         $subcompiler = new Compiler($a);
         $compiler->write($subcompiler->compile());
     }
     $compiler->write(')?>');
 }
예제 #13
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write($this->value);
 }
예제 #14
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('\'' . $this->value . '\'');
 }
예제 #15
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write('<?php else: ?>');
 }
예제 #16
0
 public function compile(CompilerInterface $compiler)
 {
     $compiler->write($this->getValue());
 }