Class: Bridgetown::ERBView

Inherits:
RubyTemplateView show all
Defined in:
lib/bridgetown-core/converters/erb_templates.rb

Direct Known Subclasses

PureRubyView, SerbeaView

Instance Attribute Summary

Attributes inherited from RubyTemplateView

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

Instance Method Summary collapse

Methods inherited from RubyTemplateView

#collections, #data, #data_key?, #helpers, #initialize, #inspect, #liquid_render, #method_missing, #render, #respond_to_missing?, #site_drop

Methods included from Streamlined

#helper

Methods included from ERBCapture

#capture

Constructor Details

This class inherits a constructor from Bridgetown::RubyTemplateView

Dynamic Method Handling

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

Instance Method Details

#_render_partial(partial_name, options) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bridgetown-core/converters/erb_templates.rb', line 88

def _render_partial(partial_name, options)
  partial_path = _partial_path(partial_name, "erb")
  site.tmp_cache["partial-tmpl:#{partial_path}"] ||= {
    signal: site.config.fast_refresh ? Signalize.signal(1) : nil,
  }
  tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"]
  tmpl.template ||= Tilt::ErubiTemplate.new(
    partial_path,
    outvar: "@_erbout",
    bufval: "Bridgetown::OutputBuffer.new",
    engine_class: ERBEngine
  )
  tmpl.signal&.value # subscribe so resources are attached to this partial within effect
  tmpl.template.render(self, options)
end

#h(input) ⇒ Object



76
77
78
# File 'lib/bridgetown-core/converters/erb_templates.rb', line 76

def h(input)
  Erubi.h(input)
end

#partial(partial_name = nil, **options, &block) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/bridgetown-core/converters/erb_templates.rb', line 80

def partial(partial_name = nil, **options, &block)
  partial_name = options[:template] if partial_name.nil? && options[:template]
  options.merge!(options[:locals]) if options[:locals]
  options[:content] = capture(&block) if block

  _render_partial partial_name, options
end