Class: ActionView::TemplateHandlers::Builder

Inherits:
ActionView::TemplateHandler show all
Defined in:
lib/action_view/template_handlers/builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActionView::TemplateHandler

#initialize, #render

Constructor Details

This class inherits a constructor from ActionView::TemplateHandler

Class Method Details

.line_offset ⇒ Object



6
7
8
# File 'lib/action_view/template_handlers/builder.rb', line 6

def self.line_offset
  2
end

Instance Method Details

#compile(template) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/action_view/template_handlers/builder.rb', line 10

def compile(template)
  content_type_handler = (@view.send!(:controller).respond_to?(:response) ? "controller.response" : "controller")
  "#{content_type_handler}.content_type ||= Mime::XML\n" +
  "xml = Builder::XmlMarkup.new(:indent => 2)\n" +
  template +
  "\nxml.target!\n"
end