./lib/jbuilder_template.rb in jbuilder-0.3.1 vs ./lib/jbuilder_template.rb in jbuilder-0.3.2

- old
+ new

@@ -16,8 +16,23 @@ def _new_instance __class__.new(@context) 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