Sha256: cdcd3a3439db154c8ccedd471783ccc953c00a385add84db11e0888a9d4b384e
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
# encoding: utf-8 # this class helps with haml layout files class EasyHtmlGenerator::Generator::Compile::Haml::Layout @layouts = {} def self.layout_from_file(haml_folder, template, haml_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}layout.haml" unless File.exist? path load_from_file(path, haml_config) if should_load_from_file path @layouts[path] end def self.should_load_from_file(layout_file) return true unless @layouts.key? layout_file EasyHtmlGenerator::Checksum.file_changed? layout_file end def self.load_from_file(layout_file, haml_config) fail "layout not found '#{path}'" unless File.exist? layout_file @layouts[layout_file] = Haml::Engine.new(File.read(layout_file), haml_config) EasyHtmlGenerator::Checksum.store_file(layout_file) end end
Version data entries
6 entries across 6 versions & 1 rubygems