Allow caller to specify path/line when rendering with Proc or String.

This commit is contained in:
Niall Smart 2013-08-16 18:27:52 -07:00 committed by Zachary Scott
parent f98c81d68e
commit 2330449a0d
1 changed files with 3 additions and 1 deletions

View File

@ -861,7 +861,9 @@ module Sinatra
end
when Proc, String
body = data.is_a?(String) ? Proc.new { data } : data
path, line = settings.caller_locations.first
caller = settings.caller_locations.first
path = options[:path] || caller[0]
line = options[:line] || caller[1]
template.new(path, line.to_i, options, &body)
else
raise ArgumentError, "Sorry, don't know how to render #{data.inspect}."