public function ScssCompilerService::replaceTokens in SCSS/Less Compiler 8
Replace path tokens into real path.
Parameters
string $path: String for replacement.
Overrides ScssCompilerInterface::replaceTokens
1 call to ScssCompilerService::replaceTokens()
- ScssCompilerService::buildCompilationFileInfo in src/
ScssCompilerService.php - Returns compile file info.
File
- src/
ScssCompilerService.php, line 339
Class
- ScssCompilerService
- Defines a class for scss compiler service.
Namespace
Drupal\scss_compilerCode
public function replaceTokens($path) {
// If string starts with @ replace it with the proper path.
if (!is_string($path)) {
return $path;
}
if (substr($path, 0, 1) === '@') {
$namespace = [];
if (preg_match('#([^/]+)/#', $path, $namespace)) {
$namespace_path = $this
->getNamespacePath(substr($namespace[1], 1));
if (!$namespace_path) {
return FALSE;
}
$path = str_replace($namespace[1], $namespace_path, $path);
}
else {
if (!($namespace_path = $this
->getNamespacePath(substr($path, 1)))) {
return FALSE;
}
$path = $namespace_path;
}
}
return $path;
}