Skip to content

Commit

Permalink
Fix rendering with extensions, e.g. resource.html.haml
Browse files Browse the repository at this point in the history
  • Loading branch information
cehoffman committed Jan 30, 2010
1 parent e5f2f0e commit 55f790d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/sinatra/respond_to.rb
Expand Up @@ -136,11 +136,18 @@ def self.registered(app)

app.class_eval do
private
def render_with_format(*args)
# Changes in 1.0 Sinatra reuse render for layout so we store
# the original value to tell us if this is an automatic attempt
# to do a layout call. If it is, it might fail with Errno::ENOENT
# and we want to pass that back to sinatra since it isn't a MissingTemplate
# error
def render_with_format(*args, &block)
assumed_layout = args[1] == :layout
args[1] = "#{args[1]}.#{format}".to_sym if args[1].is_a?(::Symbol)
render_without_format *args
rescue Errno::ENOENT
raise MissingTemplate, "#{args[1]}.#{args[0]}"
render_without_format *args, &block
rescue Errno::ENOENT => e
raise MissingTemplate, "#{args[1]}.#{args[0]}" unless assumed_layout
raise e
end
alias_method :render_without_format, :render
alias_method :render, :render_with_format
Expand Down

0 comments on commit 55f790d

Please sign in to comment.