Class: Bridgetown::Converters::HamlTemplates

Inherits:
Converter
  • Object
show all
Defined in:
lib/bridgetown-haml/haml_templates.rb

Instance Method Summary collapse

Instance Method Details

#convert(content, convertible) ⇒ String

Logic to do the Haml content conversion.

Parameters:

  • content (String)

    Content of the file (without front matter).

Returns:

  • (String)

    The converted content.



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bridgetown-haml/haml_templates.rb', line 31

def convert(content, convertible)
  haml_view = Bridgetown::HamlView.new(convertible)

  haml_renderer = Tilt::HamlTemplate.new(convertible.relative_path) { content }

  if convertible.is_a?(Bridgetown::Layout)
    haml_renderer.render(haml_view) do
      convertible.current_document_output
    end
  else
    haml_renderer.render(haml_view)
  end
end