Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Kernel#caller_locations (2.x) #1491

Merged
merged 6 commits into from
Oct 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update method to compile block templates
  • Loading branch information
jkowens committed Oct 4, 2021
commit b3a85e1e8d7e96ac6304a618b12c374636dd0255
7 changes: 4 additions & 3 deletions lib/sinatra/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,10 @@ def compile_template(engine, data, options, views)
end

def compile_block_template(template, options, &body)
caller = settings.caller_locations.first
path = options[:path] || caller[0]
line = options[:line] || caller[1]
first_location = caller_locations.first
path, line = first_location.path, first_location.lineno
path = options[:path] || path
line = options[:line] || line
template.new(path, line.to_i, options, &body)
end
end
Expand Down