Class: Bridgetown::RubyView

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

Instance Attribute Summary

Attributes inherited from TemplateView

#content, #layout, #paginator, #resource, #site

Instance Method Summary collapse

Methods inherited from ERBView

#h, #partial

Methods inherited from TemplateView

#collections, #data, #data_key?, #helpers, #initialize, input, #inspect, #liquid_render, #method_missing, new_with_data, #partial, render, #respond_to_missing?, #site_drop, #template_view_classes, virtual_view

Methods included from Streamlined

#helper

Methods included from ERBCapture

#capture

Constructor Details

This class inherits a constructor from Bridgetown::TemplateView

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bridgetown::TemplateView

Instance Method Details

#output_bufferOutputBuffer?

Returns:



31
# File 'bridgetown-core/lib/bridgetown-core/converters/ruby_templates.rb', line 31

def output_buffer = @_erbout

#render(item = nil, **options, &block) ⇒ Object

rubocop:disable Metrics



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'bridgetown-core/lib/bridgetown-core/converters/ruby_templates.rb', line 9

def render(item = nil, **options, &block) # rubocop:disable Metrics
  return @_erbout if !block && options.empty? && item.nil?

  if item.is_a?(Proc) || (block && item.nil?)
    result = item.is_a?(Proc) ? item.() : yield
    return result if result.is_a?(OutputBuffer)

    @_erbout ||= OutputBuffer.new
    @_erbout << result.to_s.html_safe

    return @_erbout
  end

  if item.respond_to?(:render_in)
    result = item.render_in(self, &block)
    result&.to_s&.html_safe
  else
    partial(item, **options, &block)&.html_safe
  end
end