Allow spaces in inline template names (still ignoring trailing spaces).

This commit is contained in:
Konstantin Haase 2010-09-19 13:26:26 +02:00
parent f96c6ef7d8
commit 7f2b234ffe
2 changed files with 5 additions and 1 deletions

View File

@ -824,7 +824,7 @@ module Sinatra
template = nil
data.each_line do |line|
lines += 1
if line =~ /^@@\s*(\S*)/
if line =~ /^@@\s*(.*\S)\s*$/
template = ''
templates[$1.to_sym] = [template, file, lines]
elsif template

View File

@ -87,6 +87,7 @@ class TemplatesTest < Test::Unit::TestCase
it 'ignores spaces after names of inline templates' do
mock_app { enable :inline_templates }
assert_equal "There's a space after 'bar'!\n\n", @app.templates[:bar][0]
assert_equal "this is not foo\n\n", @app.templates[:"foo bar"][0]
end
it 'loads templates from given source file' do
@ -162,6 +163,9 @@ this is foo
@@ bar
There's a space after 'bar'!
@@ foo bar
this is not foo
@@ layout
X
= yield