Module: MirrorMirror::SassPatch
- Defined in:
- lib/mirror-mirror/sass_patch.rb
Overview
Sass should provide hooks for getting access to the AST a various stages of transformation. So that we don’t have to monkeypatch it.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mirror-mirror/sass_patch.rb', line 7 def self.included(base) if base.respond_to?(:css_tree, true) # Sass >= 3.3 base.send(:alias_method, :css_tree_without_mirror_mirror, :css_tree) base.send(:alias_method, :css_tree, :css_tree_with_mirror_mirror) else # Sass < 3.3 base.send(:alias_method, :render_without_mirror_mirror, :render) base.send(:alias_method, :render, :render_with_mirror_mirror) end end |
Instance Method Details
#css_tree_with_mirror_mirror ⇒ Object
19 20 21 22 23 |
# File 'lib/mirror-mirror/sass_patch.rb', line 19 def css_tree_with_mirror_mirror root = css_tree_without_mirror_mirror MirrorVisitor.visit(root) root end |
#render_with_mirror_mirror ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/mirror-mirror/sass_patch.rb', line 25 def render_with_mirror_mirror Sass::Tree::Visitors::CheckNesting.visit(self) result = Sass::Tree::Visitors::Perform.visit(self) Sass::Tree::Visitors::CheckNesting.visit(result) # Check again to validate mixins result, extends = Sass::Tree::Visitors::Cssize.visit(result) Sass::Tree::Visitors::Extend.visit(result, extends) MirrorVisitor.visit(result) result.to_s end |