Module: HamlSupport

Defined in:
lib/calatrava/tasks/haml.rb

Defined Under Namespace

Classes: Helper

Class Method Summary collapse

Class Method Details

.compile(haml_path, html_dir, options = {}) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/calatrava/tasks/haml.rb', line 50

def compile(haml_path, html_dir, options = {})
  puts "haml: #{haml_path} -> #{html_dir}"

  options[:helper] ||= Helper.new
  options[:template] = haml_path
  options[:out] = File.join(html_dir, File.basename(haml_path, '.*') + '.html')

  render_haml(options)
end

.compile_hybrid_page(page_path, output_path, options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/calatrava/tasks/haml.rb', line 40

def compile_hybrid_page(page_path, output_path, options = {})
  puts "haml page: #{page_path} -> #{output_path}"

  options[:helper] = Helper.new(page_path)
  options[:template] = "shell/layouts/single_page.haml"
  options[:out] = File.join(output_path, File.basename(page_path, '.*') + '.html')

  render_haml(options)
end

.render_haml(options) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/calatrava/tasks/haml.rb', line 60

def render_haml(options)
  html_path = options[:out]
  template = IO.read(options[:template])

  html = Haml::Engine.new(template).render(options[:helper])

  IO.write(html_path, html)
end