Is it possible to use a variable defined in the config.rb file of a compass project, throughout the SCSS files?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
In your config.rb file add a custom module:
And then set up your variables (again, in the config.rb file):
Then in your scss file, you can use the
custom_color()
function:You could also write another custom function which returns other types such as font sizes, measurements, etc. by passing in strings, and then returning the appropriate class instance.
Interestingly, this would allow you to pass in environment variables into the compass command line, and that would generate different results.
So if you sass_options are:
And you run compass:
Then whatever color you pass in on the command line will appear in the resultant css. If you're using Heroku, you could
heroku config:set MAIN_COLOR=#224411
and be able to set template colors on a per-app basis, using the same scss files.