Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use Mime::JSON as the default response type #12

Merged
merged 1 commit into from

3 participants

@whitequark

Other template builders (e.g. XML) set their default format. Make jbuilder consistent with that.

@dhh dhh merged commit 46679c6 into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2012
  1. @inossidabile @whitequark

    Use Mime::JSON as the default response type

    inossidabile authored whitequark committed
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 3 deletions.
  1. +18 −3 lib/jbuilder_template.rb
View
21 lib/jbuilder_template.rb
@@ -18,6 +18,21 @@ def _new_instance
end
end
-ActionView::Template.register_template_handler :jbuilder, Proc.new { |template|
- "if defined?(json); #{template.source}; else; JbuilderTemplate.encode(self) do |json|;#{template.source};end; end;"
-}
+class JbuilderHandler
+ cattr_accessor :default_format
+ self.default_format = Mime::JSON
+
+ def self.call(template)
+ %{
+ if defined?(json)
+ #{template.source}
+ else
+ JbuilderTemplate.encode(self) do |json|
+ #{template.source}
+ end
+ end
+ }
+ end
+end
+
+ActionView::Template.register_template_handler :jbuilder, JbuilderHandler
Something went wrong with that request. Please try again.