Permalink
Browse files

the errors you get back are totally cryptic since the source is inclu…

…ded twice, this patch keeps the lines aligned that in turn ensure you get the correct error line numbers.
  • Loading branch information...
1 parent e2a6616 commit bb8f7236c7ffd7f38c8143f58e58ff8c642d1564 @SamSaffron SamSaffron committed Jul 24, 2012
Showing with 4 additions and 9 deletions.
  1. +4 −9 lib/jbuilder_template.rb
View
@@ -30,15 +30,10 @@ class JbuilderHandler
self.default_format = Mime::JSON
def self.call(template)
- %{
- if defined?(json)
- #{template.source}
- else
- JbuilderTemplate.encode(self) do |json|
- #{template.source}
- end
- end
- }
+
+ # this juggling is required to keep line numbers right in the error
+ %{__already_defined = defined?(json); json||=JbuilderTemplate.new(self); #{template.source}
+ json.target! unless __already_defined}
end
end

0 comments on commit bb8f723

Please sign in to comment.