Leafo\ScssPhp\Compiler::registerFunction PHP Method

registerFunction() public method

Register function
public registerFunction ( string $name, callable $func, array $prototype = null )
$name string
$func callable
$prototype array
    public function registerFunction($name, $func, $prototype = null)
    {
        $this->userFunctions[$this->normalizeName($name)] = [$func, $prototype];
    }

Usage Example

 public function filterLoad(AssetInterface $asset)
 {
     $sc = new Compiler();
     if ($this->compass) {
         new \scss_compass($sc);
     }
     if ($dir = $asset->getSourceDirectory()) {
         $sc->addImportPath($dir);
     }
     foreach ($this->importPaths as $path) {
         $sc->addImportPath($path);
     }
     foreach ($this->customFunctions as $name => $callable) {
         $sc->registerFunction($name, $callable);
     }
     if ($this->formatter) {
         $sc->setFormatter($this->formatter);
     }
     if (!empty($this->variables)) {
         $sc->setVariables($this->variables);
     }
     $asset->setContent($sc->compile($asset->getContent()));
 }
Compiler