我正在尝试使用Sass::Engine.new
. 我遇到了一个问题,我不知道如何让它允许@import GEMMIFIED_SASS_MODULE
。例如,这就是我正在尝试的:
?> 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>'
当我将一些 sass 放入文件并@import blueprint/reset
在顶部使用时,这样做没有问题,它能够在开发模式和 via 中即时编译为 CSS rake assets:precompile
。但是我有一个新的用例,我需要自己渲染一些并且遇到了这个问题。在尝试渲染它之前,我尝试添加require 'compass'
,require 'compass-rails'
和require 'compass/rails'
,但它不起作用。需要工作(因为它说true
或在需要文件之后),但在我的通话false
中似乎仍然不可用。Sass::Engine.new().render
在我的 Gemfile 中,我有:
gem 'haml-rails'
gem 'sass-rails'
gem 'compass-rails'