Nette\Bridges\ApplicationDI\LatteExtension::addMacro PHP Method

addMacro() public method

public addMacro ( $macro ) : void
return void
    public function addMacro($macro)
    {
        $builder = $this->getContainerBuilder();
        $definition = $builder->getDefinition($this->prefix('latteFactory'));
        if (isset($macro[0]) && $macro[0] === '@') {
            if (strpos($macro, '::') === FALSE) {
                $method = 'install';
            } else {
                list($macro, $method) = explode('::', $macro);
            }
            $definition->addSetup('?->onCompile[] = function ($engine) { ?->' . $method . '($engine->getCompiler()); }', ['@self', $macro]);
        } else {
            if (strpos($macro, '::') === FALSE && class_exists($macro)) {
                $macro .= '::install';
            }
            $definition->addSetup('?->onCompile[] = function ($engine) { ' . $macro . '($engine->getCompiler()); }', ['@self']);
        }
    }