Class: ActionView::TemplateHandlers::ErtTemplate

Inherits:
TemplateHandler
  • Object
show all
Includes:
Compilable
Defined in:
lib/erector/rails2/template_handlers/ert_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.line_offsetObject


5
6
7
# File 'lib/erector/rails2/template_handlers/ert_handler.rb', line 5

def self.line_offset
  2
end

Instance Method Details

#compile(template) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/erector/rails2/template_handlers/ert_handler.rb', line 13

def compile(template)
  [
    "extend ::Erector::Mixin",
    "@output_buffer = ''",
    "memoized_instance_variables = instance_variables.inject({}) do |all, instance_variable|",
    "  all[instance_variable] = instance_variable_get(instance_variable)",
    "  all",
    "end",
    "r = (controller.ert_template_base_class || ::Erector).inline do",
    "  memoized_instance_variables.each do |instance_variable, value|",
    "    instance_variable_set(instance_variable, value)",
    "  end",
    template.source,
    "end",
    "r.to_s",
  ].join("; ")
end