Class: ActionView::Template::Handlers::ERB::Erubi

Inherits:
Erubi::Engine
  • Object
show all
Defined in:
actionview/lib/action_view/template/handlers/erb/erubi.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, properties = {}) ⇒ Erubi

:nodoc: all



11
12
13
14
15
16
17
18
19
20
21
22
# File 'actionview/lib/action_view/template/handlers/erb/erubi.rb', line 11

def initialize(input, properties = {})
  @newline_pending = 0

  # Dup properties so that we don't modify argument
  properties = Hash[properties]
  properties[:preamble]   = ""
  properties[:postamble]  = "@output_buffer.to_s"
  properties[:bufvar]     = "@output_buffer"
  properties[:escapefunc] = ""

  super
end

Instance Method Details

#evaluate(action_view_erb_handler_context) ⇒ Object



24
25
26
27
28
29
30
31
# File 'actionview/lib/action_view/template/handlers/erb/erubi.rb', line 24

def evaluate(action_view_erb_handler_context)
  src = @src
  view = Class.new(ActionView::Base) {
    include action_view_erb_handler_context._routes.url_helpers
    class_eval("define_method(:_template) { |local_assigns, output_buffer| #{src} }", defined?(@filename) ? @filename : "(erubi)", 0)
  }.empty
  view._run(:_template, nil, {}, ActionView::OutputBuffer.new)
end