Class: EasyHtmlGenerator::Generator::Compile::Sass
- Defined in:
- lib/easy_html_generator/generator/compile/sass.rb
Overview
this generator compiles sass files from src folder and copies them to the dist folder
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #do_input!(input, input_file = 'inline', *_args) ⇒ Object
- #file_changed?(file) ⇒ Boolean
-
#initialize(project, config) ⇒ Sass
constructor
A new instance of Sass.
- #input_to_output_file(input_file, config) ⇒ Object
Methods inherited from Base
#do_file, #generate!, #walk_files
Methods inherited from Base
#enabled?, #generate, #generate!, #log, #log_running, #repetitive?, #store_file_hash, #tasks
Constructor Details
#initialize(project, config) ⇒ Sass
Returns a new instance of Sass.
18 19 20 21 22 |
# File 'lib/easy_html_generator/generator/compile/sass.rb', line 18 def initialize(project, config) super(project, config) self.class.add_load_path "#{@project.src_path_to :styles}" end |
Class Method Details
.add_load_path(path) ⇒ Object
12 13 14 |
# File 'lib/easy_html_generator/generator/compile/sass.rb', line 12 def self.add_load_path(path) ::Sass.load_paths << path unless ::Sass.load_paths.include?(path) end |
Instance Method Details
#do_input!(input, input_file = 'inline', *_args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/easy_html_generator/generator/compile/sass.rb', line 24 def do_input!(input, input_file = 'inline', *_args) renderer = ::Sass::Engine.new(input) result = renderer.render return result unless @config.minimize EasyHtmlGenerator::Generator::Minimize::Css.compress result rescue StandardError => e raise e, "#{e.} in #{input_file} ", e.backtrace end |
#file_changed?(file) ⇒ Boolean
35 36 37 38 |
# File 'lib/easy_html_generator/generator/compile/sass.rb', line 35 def file_changed?(file) # regenerate all sass files except imported once !File.basename(file).start_with? '_' end |
#input_to_output_file(input_file, config) ⇒ Object
40 41 42 |
# File 'lib/easy_html_generator/generator/compile/sass.rb', line 40 def input_to_output_file(input_file, config) super(input_file, config).gsub('.css.sass', '.css') end |