class Bridgetown::Converters::ERBTemplates
Public Instance Methods
convert(content, convertible)
click to toggle source
Logic to do the ERB content conversion.
@param content [String] Content of the file (without front matter). @param convertible [Bridgetown::Page, Bridgetown::Document
, Bridgetown::Layout]
The instantiated object which is processing the file.
@return [String] The converted content.
# File lib/bridgetown-core/converters/erb_templates.rb, line 111 def convert(content, convertible) return content if convertible.data[:template_engine] != "erb" erb_view = Bridgetown::ERBView.new(convertible) erb_renderer = Tilt::ErubiTemplate.new( convertible.relative_path, line_start(convertible), outvar: "@_erbout", bufval: "Bridgetown::OutputBuffer.new", engine_class: ERBEngine ) { content } if convertible.is_a?(Bridgetown::Layout) erb_renderer.render(erb_view) do convertible.current_document_output.html_safe end else erb_renderer.render(erb_view) end end
matches(ext, convertible)
click to toggle source
Calls superclass method
Bridgetown::Converter#matches
# File lib/bridgetown-core/converters/erb_templates.rb, line 133 def matches(ext, convertible) if convertible.data[:template_engine] == "erb" || (convertible.data[:template_engine].nil? && @config[:template_engine] == "erb") convertible.data[:template_engine] = "erb" return true end super(ext).tap do |ext_matches| convertible.data[:template_engine] = "erb" if ext_matches end end
output_ext(ext)
click to toggle source
# File lib/bridgetown-core/converters/erb_templates.rb, line 146 def output_ext(ext) ext == ".erb" ? ".html" : ext end