Module: Erector::Sass
- Included in:
- HTMLWidget, Widget
- Defined in:
- lib/erector/sass.rb
Overview
Adds sass support to Erector widgets.
Sass is an *optional dependency* of the Erector gem, so a call to sass
inside a widget will fail unless you have already installed the sass gem (e.g. “gem ‘sass’” in your code or Gemfile).
Current support is barebones. Please offer suggestions (or better yet, patches) for whether and how to support, e.g., caching, loading from files, precompilation, etc.
It seems to me that SASS/SCSS should be part of the Page widget, which would allow all the little style snippets to be compiled together and appear in the document HEAD.
Instance Method Summary collapse
Instance Method Details
#sass(arg, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/erector/sass.rb', line 16 def sass(arg, = {}) require "sass" = {:cache => false}.merge() if arg =~ /[\w\.*]\.s?css/i [:filename] = arg sass_text = File.read(arg) else sass_text = arg end style raw(::Sass.compile(sass_text, )) end |
#scss(arg, options = {}) ⇒ Object
28 29 30 |
# File 'lib/erector/sass.rb', line 28 def scss(arg, = {}) sass arg, {:syntax => :scss}.merge() end |