如何在sass中保留引用字符
如何在sass中保留或转义路径。我们有像如何在sass中保留引用字符,sass,node-sass,gulp-ruby-sass,Sass,Node Sass,Gulp Ruby Sass,如何在sass中保留或转义路径。我们有像“Page\Footer\CustomBar\Logo”这样的字符串,它们在内部被(错误地)转换为“Page\Footer\customBarLogo”我们如何保留ascii格式?我们试过飞镖和红宝石 Page\Footer\CustomBar\Logo将是预期结果。我搜索了一点,但没有找到任何内置方法来完成您需要的操作。似乎反斜杠很难用SASS来操纵。然而,以下是我如何获得您的路径: @function createPath($path...) {
“Page\Footer\CustomBar\Logo”
这样的字符串,它们在内部被(错误地)转换为“Page\Footer\customBarLogo”
我们如何保留ascii格式?我们试过飞镖和红宝石
Page\Footer\CustomBar\Logo
将是预期结果。我搜索了一点,但没有找到任何内置方法来完成您需要的操作。似乎反斜杠很难用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
是如何工作的,我找到了解决方案,这多亏了。我搜索了一下,但没有找到任何内置方法来满足您的需要。似乎反斜杠很难用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
是如何工作的,我找到了解决方案,这多亏了。感谢Arkellys的帮助,但这并不能真正解决我们的问题,因为我们用字符串将数据结构注入到sass代码中。当然,我们可以为这个属性设置一个数组,但我想,设置两个反斜杠更合理,这样可以很好地工作。我会在接下来的几天里看看我是否能在这个问题上找到更多的意见。谢谢。@Rob哦,好的,我想你应该编辑你的问题,然后再添加更多细节。:)感谢Arkellys的帮助,但这并不能真正解决我们的问题,因为我们使用字符串将数据结构注入到sass代码中。当然,我们可以为这个属性设置一个数组,但我想,设置两个反斜杠更合理,这样可以很好地工作。我会在接下来的几天里看看我是否能在这个问题上找到更多的意见。谢谢。@Rob哦,好的,我想你应该编辑你的问题,然后再添加更多细节。:)