Class: EasyHtmlGenerator::Generator::Compile::Haml
- Defined in:
- lib/easy_html_generator/generator/compile/haml.rb
Overview
this generator compiles haml files from src folder and copies them to the dist folder
Defined Under Namespace
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #do_input(input, layout, context, scope) ⇒ Object
- #do_input!(input, input_file, *_args) ⇒ Object
- #file_changed?(file) ⇒ Boolean
- #input_to_output_file(input_file, config) ⇒ Object
Methods inherited from Base
#do_file, #generate!, #walk_files, #watch_files
Methods inherited from Base
#enabled?, #generate, #generate!, #initialize, #log, #log_running, #repetitive?, #store_file_hash, #tasks
Constructor Details
This class inherits a constructor from EasyHtmlGenerator::Generator::Base
Instance Method Details
#do_input(input, layout, context, scope) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/easy_html_generator/generator/compile/haml.rb', line 26 def do_input(input, layout, context, scope) result = layout.render(context, body_class: scope) do body = Haml::Engine.new(input, @config.renderer) body.render(context) end return result unless @config.minimize EasyHtmlGenerator::Generator::Minimize::Html.compress result end |
#do_input!(input, input_file, *_args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/easy_html_generator/generator/compile/haml.rb', line 13 def do_input!(input, input_file, *_args) file_name = File.basename input_file scope = file_name.split('.').first context = Context.new(@project, @config, scope) layout = Layout.layout_from_file(@project.src_path_to(:views), input_file, @config) do_input(input, layout, context, scope) rescue StandardError => e raise e, "#{e.} in #{input_file} ", e.backtrace end |
#file_changed?(file) ⇒ Boolean
37 38 39 40 |
# File 'lib/easy_html_generator/generator/compile/haml.rb', line 37 def file_changed?(file) # regenerate all haml files except imported once !File.basename(file).start_with? '_' end |
#input_to_output_file(input_file, config) ⇒ Object
42 43 44 |
# File 'lib/easy_html_generator/generator/compile/haml.rb', line 42 def input_to_output_file(input_file, config) super(input_file, config).gsub('.html.haml', '.html') end |