/** * {label ...} and optionally {/label} */ public function macroLabel(MacroNode $node, $writer) { $cmd = 'if ($_label = $_form[%node.word]->getLabel()) echo $_label->addAttributes(%node.array)'; if ($node->isEmpty = substr($node->args, -1) === '/') { $node->setArgs(substr($node->args, 0, -1)); return $writer->write($cmd); } else { return $writer->write($cmd . '->startTag()'); } }
/** * @param \Nette\Latte\MacroNode $node * @param \Nette\Latte\PhpWriter $writer * @return string */ public function macroFormBegin(MacroNode $node, PhpWriter $writer) { if ($node->isEmpty = substr($node->args, -1) === '/') { $node->setArgs(substr($node->args, 0, -1)); return $writer->write('$form = $__form = $_form = (is_object(%node.word) ? %node.word : $_control->getComponent(%node.word)); $__form->render(NULL, %node.array);'); } $word = $node->tokenizer->fetchWord(); $node->isEmpty = in_array($word, array('errors', 'body', 'controls', 'buttons')); $node->tokenizer->reset(); return $writer->write('$form = $__form = $_form = ' . get_called_class() . '::renderFormPart(%node.word, %node.array, get_defined_vars())'); }
/** * {label} for {input} in {inputlist} */ public function macroLabel(MacroNode $node, $writer) { if (!$this->inList || $node->args && $node->args !== '/' && strpos($node->args, '=>') === FALSE) { return FALSE; } $cmd = 'echo $_inputlist->getItemLabel($_inputlistKey)->addAttributes(%node.array)'; if ($node->isEmpty = substr($node->args, -1) === '/') { $node->setArgs(substr($node->args, 0, -1)); return $writer->write($cmd); } else { return $writer->write($cmd . '->startTag()'); } }
/** * Table heading controls * @param \Nette\Latte\MacroNode $node * @param \Nette\Latte\PhpWriter $writer * @return string */ public function macroControls(Latte\MacroNode $node, Latte\PhpWriter $writer) { $code = '$_column = is_object(%node.word) ? %node.word : $_table[%node.word]; if ($_column->isSortable()) : ?> <td> <div class="order"> <a href="<?php echo $_control->link(\'this!\', array(\'order\' => $_column->name, \'sort\' => false)); ?>"><span>Ascending</span></a> <a href="<?php echo $_control->link(\'this!\', array(\'order\' => $_column->name, \'sort\' => true)); ?>"><span>Descending</span></a> </div> <?php echo $_form[$_column->getColumn()]->getControl()->addAttributes(%node.array); ?> </td> <?php endif;'; if ($node->isEmpty = substr($node->args, -1) === '/') { $node->setArgs(substr($node->args, 0, -1)); } return $writer->write($code); }
public function macroGettext(\Nette\Latte\MacroNode $node, $writer) { $args = $node->args; $prefix = ''; if (strpos($args, 'np') === 0) { $args = substr($args, 2); $prefix = "np"; } elseif (strpos($args, 'n') === 0) { $args = substr($args, 1); $prefix = "n"; } elseif (strpos($args, 'p') === 0) { $args = substr($args, 1); $prefix = "p"; } $node->setArgs($args); return $writer->write('echo %modify($template->' . $prefix . 'gettext(%node.args))'); }
function macroLabel(MacroNode $node, PhpWriter $writer) { $cmd = '$_input = is_object(%node.word) ? %node.word : $_form[%node.word]; if ($_label = $_input->getLabel()) echo $_label->addAttributes(%node.array)'; if ($node->isEmpty = substr($node->args, -1) === '/') { $node->setArgs(substr($node->args, 0, -1)); return $writer->write($cmd); } else { return $writer->write($cmd . '->startTag()'); } }
static($compiler);$me->addMacro('form','Nette\Latte\Macros\FormMacros::renderFormBegin($form = $_form = (is_object(%node.word) ? %node.word : $_control[%node.word]), %node.array)','Nette\Latte\Macros\FormMacros::renderFormEnd($_form)');$me->addMacro('label',array($me,'macroLabel'),'?></label><?php');$me->addMacro('input','echo $_form[%node.word]->getControl()->addAttributes(%node.array)',NULL,array($me,'macroAttrInput'));$me->addMacro('formContainer','$_formStack[] = $_form; $formContainer = $_form = $_form[%node.word]','$_form = array_pop($_formStack)');}function macroLabel(MacroNode$node,PhpWriter$writer){$cmd='if ($_label = $_form[%node.word]->getLabel()) echo $_label->addAttributes(%node.array)';if($node->isEmpty=(substr($node->args,-1)==='/')){$node->setArgs(substr($node->args,0,-1));return$writer->write($cmd);}else{return$writer->write($cmd.'->startTag()');}}function