Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed an uncought exception when run on the Google App Engine infrast…

…ructure.

Signed-off-by: Simon Rozet <simon@rozet.name>
  • Loading branch information...
commit b88c0f579aabf4d32e8b6c2e3d861506e0f9a8f1 1 parent 9d67449
Samuel Goebert authored rtomayko committed
Showing with 18 additions and 1 deletion.
  1. +8 −1 lib/sinatra/base.rb
  2. +10 −0 test/templates_test.rb
View
9 lib/sinatra/base.rb
@@ -635,7 +635,14 @@ def layout(name=:layout, &block)
# when no file is specified.
def use_in_file_templates!(file=nil)
file ||= caller_files.first
- if data = ::IO.read(file).split('__END__')[1]
+
+ begin
+ data = ::IO.read(file).split('__END__')[1]
+ rescue
+ data = nil
+ end
+
+ if data
data.gsub!(/\r\n/, "\n")
template = nil
data.each_line do |line|
View
10 test/templates_test.rb
@@ -75,6 +75,16 @@ def with_default_layout
assert_equal "this is foo\n\n", @app.templates[:foo]
assert_equal "X\n= yield\nX\n", @app.templates[:layout]
end
+
+ test 'use_in_file_templates simply ignores IO errors' do
+ assert_nothing_raised {
+ mock_app {
+ use_in_file_templates!('/foo/bar')
+ }
+ }
+
+ assert @app.templates.empty?
+ end
end
__END__
Please sign in to comment.
Something went wrong with that request. Please try again.