Better handling of in file templates

`__END__` in the middle of lines should not be recognized as the end of
the ruby script. Ruby only accepts the line just contain `__END__`.
Beginning/tailing whitespaces are not allowed.

Signed-off-by: Simon Rozet <simon@rozet.name>
This commit is contained in:
Yoji Shidara 2009-04-17 14:17:15 +02:00 committed by Ryan Tomayko
parent b88c0f579a
commit 64d852ea6f
2 changed files with 3 additions and 1 deletions

View File

@ -637,7 +637,7 @@ module Sinatra
file ||= caller_files.first
begin
data = ::IO.read(file).split('__END__')[1]
data = ::IO.read(file).split(/^__END__$/)[1]
rescue
data = nil
end

View File

@ -87,6 +87,8 @@ class TemplatesTest < Test::Unit::TestCase
end
end
# __END__ : this is not the real end of the script.
__END__
@@ foo