Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
685 views
in Technique[技术] by (71.8m points)

ruby on rails - SASS variables not parsing correctly - Undefined variable: "$ct-white"

I am using SASS for the first time, and my variables seem to have stopped working. I have the following code in my application.css.scss file:

*= require_self
*/
@import "layout";
@import "colors";
...
@import "text";

In my partial _colors.css.scss file, there is:

...
$ct-white: #F8F8F8 !global;

and in my partial _layout.css.scss file (the Rails default layout file):

/* Site-wide layout syntax */
body {
  background-color: $ct-white;
}

I know that the _layout.css.scss file is loading because other styles on the page work fine when I set body { background-color: #F8F8F8; }. For some reason, the variable isn't being parsed correctly.

Any ideas why?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You're importing colors after layout , so the variables you define in colors are not available for layout. You could simply invert the order of those two lines. In SASS, import order matters.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...