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

macroLabel() public method

..}
public macroLabel ( MacroNode $node, PhpWriter $writer )
$node Latte\MacroNode
$writer Latte\PhpWriter
    public function macroLabel(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]; if ($_label = $_input' : 'if ($_label = end($this->global->formsStack)[%0.word]') . '->%1.raw) echo $_label' . ($node->tokenizer->isNext() ? '->addAttributes(%node.array)' : ''), $name, $words ? 'getLabelPart(' . implode(', ', array_map([$writer, 'formatWord'], $words)) . ')' : 'getLabel()');
    }

Usage Example

Exemplo n.º 1
0
 public function macroLabel(MacroNode $node, PhpWriter $writer)
 {
     return $this->getBeforeRenderCalling($writer) . parent::macroLabel($node, $writer);
 }