Using styles from inside gems in Nesta
- Tommy Sundström
- 2013-05-11 @ 12:25
I'm working on adapting Susy to Nesta.
One problem I ran into was how to reference the styles contained in the
Compass and Susy gems.
The solution I came up with was adding this in the theme's app.rb
require 'susy' # This will also require compass
# Configuring sass
sass_options = Hash.new
# Adding load_paths into gems so that sass can @import sass
stylesheets from there
# Paths for compass 0.12.2
# Path for susy 1.0.8
Pathname.new(Gem.loaded_specs['susy'].full_gem_path) + 'sass'
sass_options[:load_paths] = [compass_gem_stylesheets, susy_gem_stylesheets]
# … other sass configurations
set :sass, sass_options
set :scss, sass_options
# … other stuff
This way, stylesheets can be called using /css/master.css (if there is
a master.sass or master.scss file in the mytheme/views directory)
Note that the paths to the stylesheets are partly hard coded, so if the
internal structure of the gems changes in future versions it will break.
I suspect there are better ways to do this. But this works.