I searched a bit I didn't found any built-in way to do what you need. It seems that backslashes are hard to manipulate with SASS. However, here is how I managed to get your path:
@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}\"");
}
Calling createPath('Page', 'Footer', 'CustomBar', 'Logo');
will return "Page\Footer\CustomBar\Logo"
.
Honestly, I can't explain how the unquote
works, I found the solution thanks to this answer.