Class: Bridgetown::Converters::RubyTemplates

Inherits:
Bridgetown::Converter show all
Defined in:
bridgetown-core/lib/bridgetown-core/converters/ruby_templates.rb

Instance Method Summary collapse

Methods inherited from Bridgetown::Converter

#determine_template_engine, helper_delimiters, #initialize, input, #inspect, #line_start, #matches, #output_ext, support_slots, supports_slots?, template_engine

Methods inherited from Plugin

#initialize

Methods included from Prioritizable

#<=>, included

Constructor Details

This class inherits a constructor from Bridgetown::Converter

Instance Method Details

#convert(content, convertible) ⇒ Object

rubocop:disable Style/DocumentDynamicEvalDefinition, Style/EvalWithLocation



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'bridgetown-core/lib/bridgetown-core/converters/ruby_templates.rb', line 67

def convert(content, convertible)
  rb_view = Bridgetown::PureRubyView.new(convertible)

  rb_view.instance_eval(
    "def __ruby_template;#{content};end", convertible.path.to_s, line_start(convertible)
  )

  results = if convertible.is_a?(Bridgetown::Layout)
              rb_view.__ruby_template { convertible.current_document_output.html_safe }
            else
              rb_view.__ruby_template
            end
  (rb_view._output_buffer || results).to_s
end