Class: ActionView::TemplateHandlers::SafeErb
- Inherits:
-
TemplateHandler
- Object
- TemplateHandler
- ActionView::TemplateHandlers::SafeErb
show all
- Extended by:
- SafemodeHandler
- Defined in:
- lib/action_view/template_handlers/safe_erb.rb
Class Method Summary
collapse
Instance Method Summary
collapse
delegate_methods, helper_methods, skip_assigns, valid_assigns
Class Method Details
.line_offset ⇒ Object
10
11
12
|
# File 'lib/action_view/template_handlers/safe_erb.rb', line 10
def self.line_offset
0
end
|
Instance Method Details
#compile(template) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/action_view/template_handlers/safe_erb.rb', line 14
def compile(template)
src = template.respond_to?(:source) ? template.source : template
filename = template.filename rescue nil
erb_trim_mode = '-'
code = ::ERB.new("<% __in_erb_template=true %>#{src}", nil, erb_trim_mode, '@output_buffer').src
RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src
code.gsub!('\\','\\\\\\')
code = <<-CODE
handler = ActionView::TemplateHandlers::SafeHaml
assigns = handler.valid_assigns(@template.assigns)
methods = handler.delegate_methods(self)
code = %Q(#{code});
box = Safemode::Box.new(self, methods, #{filename.inspect}, 0)
box.eval(code, assigns, local_assigns, &lambda{ |*args| yield(*args) })
CODE
code
end
|