Class: Himg::Railtie::ErbTemplateHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/himg/railtie/template_handler.rb

Overview

Handles .himg.erb templates by pre-processing with Erb, possibly appending to @output_buffer or calling .safe_append, and then passing the result to Himg.render

Class Method Summary collapse

Class Method Details

.call(template, source) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/himg/railtie/template_handler.rb', line 16

def self.call(template, source)
  erb_handler = ActionView::Template.registered_template_handler(:erb)
  preprocessed_view_code = erb_handler.call(template, source)

  <<-CODE
    output = begin
      #{preprocessed_view_code}
    end
    Himg.render(output, **@_himg_config)
  CODE
end