Bad substitution if using color keywords as map keys
See original GitHub issueIf you use color keywords, such as white
oder black
, and use them to build classes dynamically, sass-loader substitutes them with color hashes.
This only happens when using webpack with -p
.
$testMap: (
white: (color: white)
);
@each $key in map-keys($testMap) {
.test-btn-#{$key} {
$colors: map_get($testMap, $key);
color: map-get($colors, color);
}
}
actual result:
.test-btn-#fff{
color:#fff
}
expected result:
.test-btn-white {
color: white; // or #fff because of -p
}
Versions:
...
"node-sass": "^4.5.1",
"sass-loader": "^6.0.3",
...
Using single curly quote fixes it, thought.
$testMap: (
'white': (color: white)
);
Not sure if this is an actual issue or intended as it is, because sass documentation says:
Both the keys and values in maps can be any SassScript object.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:19 (14 by maintainers)
Top Results From Across the Web
bash : Bad Substitution - Stack Overflow
So if you chmod +x your_script_file.sh and then run it with ./your_script_file.sh , or if you run it with bash your_script_file.sh , it...
Read more >Script to display all terminal colors - command line - Ask Ubuntu
Xdefaults . However when I try to use these, I always get error: Bad Substitution . Does anyone have a working script that...
Read more >Bad substitution error in zsh shell - Unix & Linux Stack Exchange
zsh has different parameter substitution than Bash, which is documented in man zshexpn . ... will loop over the keys of the array...
Read more >The Coot User Manual - MRC Laboratory of Molecular Biology
This state file contains information about the screen centre, the clipping, colour map rotation size, the symmetry radius, and other molecule related parameters ......
Read more >Bash Reference Manual - GNU.org
A sequence of characters treated as a unit by the shell. Words may not include unquoted metacharacters . Next: Shell Builtin Commands, Previous: ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hallo, I’m the maintainer of LibSass and Node Sass.
This is actually a Sass feature. When CSS colors are unquoted they’re treated as Color objects, not Strings as you might expect. This is why you can do things like color math on them.
A feature of Color objects is that when they’re output in compressed mode, Sass tries to output the shortest representation i.e.
#fff
is more “compressed” thanwhite
.If you want CSS color names to act like strings you should quote them.
@michael-ciniawsky I also think so, but the problem should be reported in any case