我試圖使用Sass::Engine.new
以編程方式將一些sass呈現到CSS中。我遇到了一個問題,我無法弄清楚如何讓它允許@import GEMMIFIED_SASS_MODULE
。舉例來說,這就是我想:Sass :: Engine.render不會導入藍圖庫...爲什麼?
?> 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/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/import_node.rb:64:in `rescue in import'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/import_node.rb:42:in `import'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/import_node.rb:25:in `imported_file'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:149:in `rescue in visit_import'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:154:in `visit_import'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `map'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `visit_children'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `block in visit'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:7:in `visit'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/tree/root_node.rb:20:in `render'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/engine.rb:299:in `_render'
from /Users/username/.rvm/gems/[email protected]_app/gems/sass-3.1.15/lib/sass/engine.rb:246:in `render'
from (irb):30
from /Users/username/.rvm/gems/[email protected]_app/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
from /Users/username/.rvm/gems/[email protected]_app/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
from /Users/username/.rvm/gems/[email protected]_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>'
我沒有問題,這樣做時,我把一些青菜到一個文件中,並在頂部使用@import blueprint/reset
,它是能夠編譯到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'
任何人有什麼我可以做,使可見圖書館的想法用無禮的話::引擎是什麼時候?我在Reference或Documentation或Documentation