Class: ComponentEmbeddedRuby::RailsHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/component_embedded_ruby/rails_handler.rb

Class Method Summary collapse

Class Method Details

.call(template, source = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/component_embedded_ruby/rails_handler.rb', line 5

def self.call(template, source = nil)
  source ||= template.source

  template_source = Template.new(
    source,
    safe_append_method: "safe_append=",
    unsafe_append_method: "append=",
    output_var_name: "@output_buffer"
  ).to_ruby

  <<~RUBY
    @output_buffer = ActionView::OutputBuffer.new('')
    #{template_source}
  RUBY
end