0

I am using RubySassCss to compile my sass files that looks like this:

styles.scss :

body{
  &.template1{
     $background-color: #fff;

     @import "_template.scss";
  }
  &.template2{
     $background-color: #000;

     @import "_template.scss";
  }
}

_template.scss:

div{
  background-color: $background-color;
}

But i get this error :

Sass::SyntaxError: Undefined variable: "$background-color".

What i was trying to do here is a templating system based on sass variables, so if i change the body className the template (css values) changes too.


UPDATE :

When i replace @import "_template.scss"; with the content of my _template file the code works like a charm, but my real _template file is too long and i have many templates and a lot of vars, so i can't use this workaround.

EssaidiM
  • 7,924
  • 1
  • 18
  • 22
  • what command are you running to compile it? I think you would only want to compile styles.scss. You may run in to that error if it's trying to compile your template scss files separately. – Brian Glaz Mar 06 '17 at 16:20
  • I am using RubySassCss as a postProcessor, and i specified in my wro.xml that only style.scss will be compiled. – EssaidiM Mar 06 '17 at 16:40

0 Answers0