Module: Gibier::HamlHelper

Included in:
Cli, StaticGenerator
Defined in:
lib/gibier/haml_helper.rb

Instance Method Summary collapse

Instance Method Details

#convert_html(haml_file, html_file, **instance_vars) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/gibier/haml_helper.rb', line 3

def convert_html(haml_file, html_file, **instance_vars)
  File.open(html_file, "w") do |f|
    engine = Haml::Engine.new(File.read(haml_file))
    context = Object.new
    instance_vars.each do |key, value|
      context.instance_variable_set(:"@#{key}", value)
    end
    f.write engine.render(context) # Tilt::StringTemplate.new().render
  end
end