Sass 3.4 Remove a slash in a string

is a workaround or any other ways to make this work on Sass 3.4 +

@mixin icon ($name, $code) { .#{$name}::before { content: str-slice("\x",1,1) + $code;} } @include icon('test', 4556); 

The code should output

.test :: before {content: "\ 4556"; }

But at 3.4+, the snapshot \ is deleted and displayed as

.test :: before {content: "x4556"; }

thanks

+2
sass compass
source share
1 answer

You stumbled upon the currently discussed issue with escape characters in Sass . It seems that at present, Sass will either add too many characters, or complete the input of the unicode character in the css output.

UPDATE:

 @mixin icon ($name, $code) { $withslash: "\"\\#{$code}\""; .#{$name}:before { content: unquote($withslash); } } @include icon('test', '4556'); 

exits

 .test:before { content: "\4556"; } 

http://sassmeister.com/gist/04f5be11c5a6b26b8ff9

Obviously, the disadvantage of this approach is that it relies on doing strange things with an escape character and tricks Sass into an unrecognizable, possibly incorrect string.

+9
source share

All Articles