Sha256: 6b31fd6b44c1c4bc7f03b0aad08b8170a9ca6188391d7f59fe8dda4c490d3fb4

Contents?: true

Size: 703 Bytes

Versions: 11

Compression:

Stored size: 703 Bytes

Contents

require 'builder'

module ActionView
  module TemplateHandlers
    class Builder < TemplateHandler
      include Compilable

      def self.line_offset
        2
      end

      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.source +
        "\nxml.target!\n"
      end

      def cache_fragment(block, name = {}, options = nil)
        @view.fragment_for(block, name, options) do
          eval('xml.target!', block.binding)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 5 rubygems

Version Path
radiant-0.7.2 vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb
vibes-bj-1.2.2 spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb
actionpack-2.1.0 lib/action_view/template_handlers/builder.rb
actionpack-2.1.1 lib/action_view/template_handlers/builder.rb
actionpack-2.1.2 lib/action_view/template_handlers/builder.rb
antfarm-0.3.0 rails/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb
antfarm-0.4.0 rails/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb
eactionpack-2.1.2 lib/action_view/template_handlers/builder.rb
radiant-0.7.0 vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb
radiant-0.7.1 vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb