In my experience with SASS, I encountered a problem. Here's an example of what I'm attempting to do:
.message-error {
background-color: red;
p& {
background-color: yellow
}
}
Desired CSS output:
.message-error {
background-color: red;
}
p.message-error {
background-color: yellow ;
}
The concept is that all elements with the .message-error class will have a red background, except if it's a paragraph element with the .message-error class, which should have a yellow background. This is just for illustrative purposes.
SASS cannot compile this code, even after trying string concatenation. Is there a plugin available that can achieve the same result?
NOTE: I understand that I could add another CSS definition like:
p.message-error{....}
...below, but I prefer to consolidate all .message-error definitions in one place.
Thank you.