Skip to content

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

Merged
merged 1 commit into from Jan 23, 2012
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.