Created
July 30, 2015 15:33
-
-
Save deep-spaced/301bf46425c389e96680 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Used in a Stylesheet model to import other Stylesheet instances. Compile like this. | |
| # The gsub is used to clean out NULL byte characters. | |
| # | |
| # class Stylesheet < ActiveRecord::Base | |
| # include SassImporters | |
| # | |
| # def compile | |
| # compressed_styles = SassC::Engine.new(self.sass.gsub("\u0000", ''), { :importer => DatabaseImporter }).render | |
| # end | |
| # end | |
| module SassImporters | |
| class DatabaseImporter < SassC::Importer | |
| def imports(name, parent_path) | |
| if ss = Stylesheets.find_by_name(name) | |
| Import.new("#{ss.name}.scss", source: ss.sass) | |
| elsif ss = Stylesheets.find_by_name("_#{name}") | |
| Import.new("_#{ss.name}.scss", source: ss.sass) | |
| else | |
| nil | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment