Я искал немного, я не нашел никакого встроенного способа сделать то, что вам нужно.Кажется, что с SASS трудно манипулировать обратными слешами.Однако вот как мне удалось найти ваш путь:
@function createPath($path...) {
$finalPath: null;
@each $el in $path {
@if($finalPath) {
// Do not add the slashes at the beginning of the string
$finalPath: $finalPath + "\\";
};
$finalPath: $finalPath + $el;
}
// At this point, $finalPath = "Page\\Footer\\CustomBar\\Logo"
@return unquote("\"#{$finalPath}\"");
}
Вызов createPath('Page', 'Footer', 'CustomBar', 'Logo');
вернет "Page\Footer\CustomBar\Logo"
.
Честно говоря, я не могу объяснить, как работает unquote
Я нашел решение благодаря этому ответу .