Class: RubyTemplateHandler::Handler

Inherits:
ActionView::TemplateHandler
  • Object
show all
Includes:
ActionView::TemplateHandlers::Compilable
Defined in:
lib/ruby_template_handler/handler.rb

Instance Method Summary collapse

Instance Method Details

#compile(template) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/ruby_template_handler/handler.rb', line 5

def compile(template)    
  unless File.basename(template.filename).starts_with?('_')
    src = 'ActiveSupport::JSON.encode(code.call)'
  else
    src = "code.call"
  end

  "code = lambda{#{template.source}};" +
  "self.output_buffer = (#{src})"
end