Brabijan\Images\Macros\Latte::macroImg PHP Method

macroImg() public method

public macroImg ( MacroNode $node, PhpWriter $writer ) : string
$node Latte\MacroNode
$writer Latte\PhpWriter
return string
    public function macroImg(MacroNode $node, PhpWriter $writer)
    {
        $this->isUsed = TRUE;
        $arguments = Helpers::prepareMacroArguments($node->args);
        if ($arguments["name"] === NULL) {
            throw new Nette\Latte\CompileException("Please provide filename.");
        }
        $namespace = $arguments["namespace"];
        unset($arguments["namespace"]);
        $arguments = array_map(function ($value) use($writer) {
            return $value ? $writer->formatWord($value) : 'NULL';
        }, $arguments);
        $command = '$_imagePipe';
        $command .= $namespace !== NULL ? '->setNamespace(' . $writer->formatWord(trim($namespace)) . ')' : '';
        $command .= '->request(' . implode(", ", $arguments) . ')';
        return $writer->write('echo %escape(' . $writer->formatWord($command) . ')');
    }