Nette\Bridges\FormsLatte\FormMacros::macroInput PHP Method

macroInput() public method

..}
public macroInput ( MacroNode $node, PhpWriter $writer )
$node Latte\MacroNode
$writer Latte\PhpWriter
    public function macroInput(MacroNode $node, PhpWriter $writer)
    {
        if ($node->modifiers) {
            throw new CompileException('Modifiers are not allowed in ' . $node->getNotation());
        }
        $words = $node->tokenizer->fetchWords();
        if (!$words) {
            throw new CompileException('Missing name in ' . $node->getNotation());
        }
        $node->replaced = true;
        $name = array_shift($words);
        return $writer->write(($name[0] === '$' ? '$_input = is_object(%0.word) ? %0.word : end($this->global->formsStack)[%0.word]; echo $_input' : 'echo end($this->global->formsStack)[%0.word]') . '->%1.raw' . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : '') . " /* line {$node->startLine} */", $name, $words ? 'getControlPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getControl()');
    }

Usage Example

Example #1
0
 public function macroInput(MacroNode $node, PhpWriter $writer)
 {
     return $this->getBeforeRenderCalling($writer) . parent::macroInput($node, $writer);
 }