Beispiel #1
0
 /**
  * Generates code.
  * @return string
  */
 private function compile(MacroNode $node, $def)
 {
     $writer = Latte\PhpWriter::using($node, $this->parser->context);
     if (is_string($def)) {
         $code = $writer->write($def);
     } else {
         $code = callback($def)->invoke($node, $writer);
         if ($code === FALSE) {
             return FALSE;
         }
     }
     return "<?php {$code} ?>";
 }
Beispiel #2
0
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(Latte\MacroNode $node)
 {
     $this->used = TRUE;
     $node->isEmpty = FALSE;
     $node->openingCode = Latte\PhpWriter::using($node)->write('<?php if (Nette\\Latte\\Macros\\CacheMacro::createCache($netteCacheStorage, %var, $_g->caches, %node.array?)) { ?>', Nette\Utils\Strings::random());
 }
Beispiel #3
0
 private function compile(MacroNode $node, $def)
 {
     $node->tokenizer->reset();
     $writer = Latte\PhpWriter::using($node, $this->compiler);
     if (is_string($def)) {
         return $writer->write($def);
     } else {
         return Nette\Callback::create($def)->invoke($node, $writer);
     }
 }
 /**
  * {link destination [,] [params]}
  * {plink destination [,] [params]}
  * n:href="destination [,] [params]"
  */
 public function macroLink(MacroNode $node, PhpWriter $writer)
 {
     $node->modifiers = preg_replace('#\\|safeurl\\s*(?=\\||\\z)#i', '', $node->modifiers);
     return $writer->using($node, $this->getCompiler())->write('echo %escape(%modify(' . ($node->name === 'plink' ? '$_presenter' : '$_control') . '->link(%node.word, %node.array?)))');
 }
Beispiel #5
0
nodeClosed(MacroNode$node){$res=$this->compile($node,$this->macros[$node->name][1]);if(!$node->closingCode){$node->closingCode="<?php $res ?>";}}private
function
compile(MacroNode$node,$def){$node->tokenizer->reset();$writer=Latte\PhpWriter::using($node,$this->compiler);if(is_string($def)){return$writer->write($def);}else{return
callback($def)->invoke($node,$writer);}}function