Sha256: cc21b1f5d8b45e3425a798b15b8a6c1d476c1f89ff8eda7ff725c32561126b13

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 Bytes

Contents

require 'action_view/base'
require 'action_view/template'

module ActionView #:nodoc:
  class Base
    cattr_accessor :pretty_print_json
    @@pretty_print_json = false
  end
end

module ActionView
  module Template::Handlers
    class JSONBuilder < Template::Handler
      include Compilable

      self.default_format = Mime::JSON

      def compile(template)
        "json = ::JSONBuilder::Generator.new(:pretty => #{ActionView::Base.pretty_print_json});" +
          template.source +
        ";json.compile!;"
      end
    end
  end
end

ActionView::Template.register_template_handler :'json.builder', ActionView::Template::Handlers::JSONBuilder

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_builder-2.0.0 lib/json_builder/template.rb