Class: EasyHtmlGenerator::Generator::Compile::Haml::Layout
- Inherits:
-
Object
- Object
- EasyHtmlGenerator::Generator::Compile::Haml::Layout
- Defined in:
- lib/easy_html_generator/generator/compile/haml/layout.rb
Overview
this class helps with haml layout files
Class Method Summary collapse
- .layout_from_file(haml_folder, template, config) ⇒ Object
- .load_from_file(layout_file, haml_config) ⇒ Object
- .should_load_from_file(layout_file) ⇒ Object
Class Method Details
.layout_from_file(haml_folder, template, config) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easy_html_generator/generator/compile/haml/layout.rb', line 7 def self.layout_from_file(haml_folder, template, config) first_line = File.readlines(template).first if first_line.include? '-# ehg layout:' name = first_line.sub('-# ehg layout:', '').strip else name = 'layout' end path = "#{haml_folder}#{name}.haml" path = "#{haml_folder}#{config.default_layout}.haml" unless File.exist? path load_from_file(path, config.renderer) if should_load_from_file path @layouts[path] end |
.load_from_file(layout_file, haml_config) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/easy_html_generator/generator/compile/haml/layout.rb', line 29 def self.load_from_file(layout_file, haml_config) fail "layout not found '#{layout_file}'" unless File.exist? layout_file @layouts[layout_file] = Haml::Engine.new(File.read(layout_file), haml_config) EasyHtmlGenerator::Checksum.store_file(layout_file) end |
.should_load_from_file(layout_file) ⇒ Object
24 25 26 27 |
# File 'lib/easy_html_generator/generator/compile/haml/layout.rb', line 24 def self.should_load_from_file(layout_file) return true unless @layouts.key? layout_file EasyHtmlGenerator::Checksum.file_changed? layout_file end |