Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #12 from whitequark/correct-mime-type

Use Mime::JSON as the default response type
  • Loading branch information...
commit 46679c6a2b152d4feaae02b9d0cf2064cf32119c 2 parents 667571e + 17e8588
@dhh dhh authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.