I use the following code snippet to manually compile the sass manifest with some added variable overrides.
template = File.read("#{Rails.root}/app/assets/schemes/#{scheme}/css/styles.css.scss")
scheme_variables.each do |key, value|
template << "$#{key}:#{value};\n"
end
engine = Sass::Engine.new(template, {
:syntax => :scss,
:cache => false,
:read_cache => false,
:style => :compressed,
:filesystem_importer => Sass::Rails::SassImporter,
:load_paths => MyApp::Application.assets.paths,
:sprockets => {
:context => ?,
:environment => MyApp::Application.assets
}
})
output = engine.render
The constructor of Sass :: Engine wants to create a context and environment for asterisks in the hash parameter settings. What do I put in context? The first thing I tried was ...
:context => MyApp::Application.assets.context_class,
... but this gives me the following error: undefined method `font_path 'for #" when it gets into one of my sass helpers.
The second thing I tried was ...
:context => ActionController::Base.helpers,
... This fixed the problem with the asset helper, but when I try to import my glob import (for example, @import "mixins / *"), the following error is raised: undefined `depend_on 'method for #
I am using Rails 4.2 and sass-rails 5.0.3.
. !