zeeraw
zeeraw

Reputation: 5207

Carry Sass variables through the Assets Pipeline, Rails 3.1 rc1

I recently branched one of my Rails 3.0 projects with the 3.1 rc1 to try the new assets pipeline. I've been using Sass in the project before going 3.1 so I've been setting up some variables and functions in a separate configure file and let all my other sass files import that one file at the first line.

This has been working out great to not repeat some color codes and general geometry through in the stylesheets. Problem is now with the new Assets Pipeline is that as I've understood it converts the ".css.sass" files to raw css before appending it to the rest of the code.

So if i specify, in my "application.css":

/*
 *= require ./configure
 *= require ./what_ever_other_files_i_want_to_import
*/

I get errors like:

Sass::SyntaxError
    Undefined variable: "$interactive".

When i try to access the file from: http://localhost:3000/assets/application.css

Any ideas?

Upvotes: 18

Views: 4532

Answers (2)

pastullo
pastullo

Reputation: 4201

Unfortunately I found out that SASS variables are be page specific.

If you want to carry your variables across all files, remove the *= require_tree . line from your application.css.scss file and replace it with the @import "layout.css.scss"; directive to manually import each sass file.

Yes you have to @import each file

Upvotes: 2

Kolja
Kolja

Reputation: 2749

Sass supports Partials. That way you can include your separate configuration in __configuration.sass_ and reference it with

@import "configuration";

from your main sass-file.

Upvotes: 15

Related Questions