I'm attempting to render some sass into CSS programmatically using Sass::Engine.new
. I'm running into a problem where I can't figure out how to get it to allow @import GEMMIFIED_SASS_MODULE
. For instance, this is what I'm trying:
?> sass = "@import \"blueprint/reset\"\nh1\n width: 100%"
=> "@import \"blueprint/reset\"\nh1\n width: 100%"
>> puts sass # For readable version
@import "blueprint/reset"
h1
width: 100%
=> nil
>> Sass::Engine.new(sass, :syntax => :sass).render
Sass::SyntaxError: File to import not found or unreadable: blueprint/reset.
Load path: /Users/username/projects/my_app
from (sass):1
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/import_node.rb:64:in `rescue in import'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/import_node.rb:42:in `import'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/import_node.rb:25:in `imported_file'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:149:in `rescue in visit_import'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:154:in `visit_import'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `map'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `visit_children'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `block in visit'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:7:in `visit'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/tree/root_node.rb:20:in `render'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/engine.rb:299:in `_render'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/sass-3.1.15/lib/sass/engine.rb:246:in `render'
from (irb):30
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /Users/username/.rvm/gems/ruby-1.9.2-p290@my_app/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have no problem doing this when I put some sass into a file and use @import blueprint/reset
at the top, it is able to compile to CSS just fine on-the-fly in development mode and via rake assets:precompile
. But I have a new use-case where I need to render some myself and am running into this issue. I've tried adding require 'compass'
, require 'compass-rails'
, and require 'compass/rails'
before I try to render it, but it doesn't work. The requires work (in that it says true
or false
after requiring the files), but it still doesn't appear to be available in my Sass::Engine.new().render
call.
In my Gemfile I have:
gem 'haml-rails'
gem 'sass-rails'
gem 'compass-rails'
Anyone have ideas of what I can do to make libraries visible when using Sass::Engine? I couldn't find anything in the Reference or the Documentation