Exemplo n.º 1
0
 /**
  * n:input
  */
 public function macroAttrInput(MacroNode $node, PhpWriter $writer)
 {
     if ($node->htmlNode->attrs) {
         $reset = array_fill_keys(array_keys($node->htmlNode->attrs), NULL);
         return $writer->write('echo $_form[%node.word]->getControl()->addAttributes(%var)->attributes()', $reset);
     }
     return $writer->write('echo $_form[%node.word]->getControl()->attributes()');
 }
Exemplo n.º 2
0
 public function templatePrepareFilters($template)
 {
     $template->registerFilter($e = new LatteFilter());
     $s = new MacroSet($e->compiler);
     $s->addMacro('helper', 'ob_start()', function ($n) {
         $w = new PhpWriter($n->tokenizer, $n->args);
         return $w->write('echo %modify(ob_get_clean())');
     });
 }
Exemplo n.º 3
0
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     $this->used = TRUE;
     $node->isEmpty = FALSE;
     $node->openingCode = PhpWriter::using($node)->write('<?php if (CacheMacro::createCache($netteCacheStorage, %var, $_g->caches, %node.array?)) { ?>', Strings::random());
 }
Exemplo n.º 4
0
 /**
  * {= ...}
  * {? ...}
  */
 public function macroExpr(MacroNode $node, PhpWriter $writer)
 {
     return $writer->write(($node->name === '?' ? '' : 'echo ') . '%modify(%node.args)');
 }
Exemplo n.º 5
0
 /**
  * Generates code.
  * @return string
  */
 private function compile(MacroNode $node, $def)
 {
     $node->tokenizer->reset();
     $writer = PhpWriter::using($node, $this->compiler);
     if (is_string($def) && substr($def, 0, 1) !== "") {
         return $writer->write($def);
     } else {
         return Callback::create($def)->invoke($node, $writer);
     }
 }
Exemplo n.º 6
0
 /**
  * {status ...}
  */
 public function macroStatus(MacroNode $node, PhpWriter $writer)
 {
     return $writer->write((substr($node->args, -1) === '?' ? 'if (!$netteHttpResponse->isSent()) ' : '') . '$netteHttpResponse->setCode(%var)', (int) $node->args);
 }