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

Inherits:
Erubi::Engine
  • Object
show all
Defined in:
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
23
24
# File '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[:bufvar]     ||= "@output_buffer"
  properties[:preamble]   ||= ""
  properties[:postamble]  ||= "#{properties[:bufvar]}.to_s"

  properties[:escapefunc] = ""

  super
end

Instance Method Details

#evaluate(action_view_erb_handler_context) ⇒ Object



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

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