Sha256: 4ef4f2ee84bdaf7fd770e8873d77074dbde75f531974cb05edd303be7d988d97

Contents?: true

Size: 650 Bytes

Versions: 6

Compression:

Stored size: 650 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

6 entries across 6 versions & 1 rubygems

Version Path
json_builder-2.0.6 lib/json_builder/template.rb
json_builder-2.0.5 lib/json_builder/template.rb
json_builder-2.0.4 lib/json_builder/template.rb
json_builder-2.0.3 lib/json_builder/template.rb
json_builder-2.0.2 lib/json_builder/template.rb
json_builder-2.0.1 lib/json_builder/template.rb