class Bridgetown::Converters::HamlTemplates

Public Instance Methods

convert(content, convertible) click to toggle source

Logic to do the Haml content conversion.

@param content [String] Content of the file (without front matter). @params convertible [Bridgetown::Page, Bridgetown::Document, Bridgetown::Layout]

The instantiated object which is processing the file.

@return [String] The converted content.

# File lib/bridgetown-haml/haml_templates.rb, line 32
def convert(content, convertible)
  return content if convertible.data[:template_engine] != "haml"

  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
matches(ext, convertible) click to toggle source
Calls superclass method
# File lib/bridgetown-haml/haml_templates.rb, line 48
def matches(ext, convertible)
  return true if convertible.data[:template_engine] == "haml"

  super(ext).tap do |ext_matches|
    convertible.data[:template_engine] = "haml" if ext_matches
  end
end
output_ext(ext) click to toggle source
# File lib/bridgetown-haml/haml_templates.rb, line 56
def output_ext(ext)
  ext == ".haml" ? ".html" : ext
end