/** * New node is found. * @return bool */ public function nodeOpened(NMacroNode $node) { $this->used = TRUE; $node->isEmpty = FALSE; $node->openingCode = NPhpWriter::using($node) ->write('<?php if (NCacheMacro::createCache($netteCacheStorage, %var, $_g->caches, %node.array?)) { ?>', NStrings::random() ); }
/** * Generates code. * @return string */ private function compile(NMacroNode $node, $def) { $node->tokenizer->reset(); $writer = NPhpWriter::using($node, $this->compiler); if (is_string($def)&& substr($def, 0, 1) !== "\0") { return $writer->write($def); } else { return NCallback::create($def)->invoke($node, $writer); } }
/** * Generates code. * @return string */ private function compile(NMacroNode $node, $def) { $node->tokenizer->reset(); $writer = NPhpWriter::using($node, $this->parser->context); if (is_string($def)&& substr($def, 0, 1) !== "\0") { $code = $writer->write($def); } else { $code = callback($def)->invoke($node, $writer); if ($code === FALSE) { return FALSE; } } return "<?php $code ?>"; }