Forked from juliocesar/sinatra.templates.on.not_found.rb
Created
January 20, 2010 23:49
-
-
Save timriley/282437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
not_found do | |
render_template_if_exists! | |
end | |
def render_template_if_exists! | |
name = File.basename(request.path) | |
Dir["#{Sinatra::Application.root}/views/#{name}.*"].each do |match| | |
@_format = File.extname(match).sub(/^./, '') | |
@_template = File.basename(match, File.extname(match)) | |
end | |
eval("#{@_format} :#{@_template}") if @_format and @_template | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment