class Bridgetown::Converters::SlimTemplates

Public Instance Methods

convert(content, convertible) click to toggle source

Logic to do the Slim 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-slim/slim_templates.rb, line 32
def convert(content, convertible)
  return content if convertible.data[:template_engine] != "slim"

  slim_view = Bridgetown::SlimView.new(convertible)

  slim_renderer = Slim::Template.new(convertible.relative_path) { content }

  if convertible.is_a?(Bridgetown::Layout)
    slim_renderer.render(slim_view) do
      convertible.current_document_output
    end
  else
    slim_renderer.render(slim_view)
  end
end
matches(ext, convertible) click to toggle source
Calls superclass method
# File lib/bridgetown-slim/slim_templates.rb, line 48
def matches(ext, convertible)
  return true if convertible.data[:template_engine] == "slim"

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