Class: Bridgetown::Converters::SlimTemplates

Inherits:
Converter
  • Object
show all
Defined in:
lib/bridgetown-slim/slim_templates.rb

Instance Method Summary collapse

Instance Method Details

#convert(content, convertible) ⇒ String

Logic to do the Slim 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-slim/slim_templates.rb', line 31

def convert(content, convertible)
  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