Allow spaces in inline template names (still ignoring trailing spaces).
This commit is contained in:
parent
f96c6ef7d8
commit
7f2b234ffe
|
@ -824,7 +824,7 @@ module Sinatra
|
||||||
template = nil
|
template = nil
|
||||||
data.each_line do |line|
|
data.each_line do |line|
|
||||||
lines += 1
|
lines += 1
|
||||||
if line =~ /^@@\s*(\S*)/
|
if line =~ /^@@\s*(.*\S)\s*$/
|
||||||
template = ''
|
template = ''
|
||||||
templates[$1.to_sym] = [template, file, lines]
|
templates[$1.to_sym] = [template, file, lines]
|
||||||
elsif template
|
elsif template
|
||||||
|
|
|
@ -87,6 +87,7 @@ class TemplatesTest < Test::Unit::TestCase
|
||||||
it 'ignores spaces after names of inline templates' do
|
it 'ignores spaces after names of inline templates' do
|
||||||
mock_app { enable :inline_templates }
|
mock_app { enable :inline_templates }
|
||||||
assert_equal "There's a space after 'bar'!\n\n", @app.templates[:bar][0]
|
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
|
end
|
||||||
|
|
||||||
it 'loads templates from given source file' do
|
it 'loads templates from given source file' do
|
||||||
|
@ -162,6 +163,9 @@ this is foo
|
||||||
@@ bar
|
@@ bar
|
||||||
There's a space after 'bar'!
|
There's a space after 'bar'!
|
||||||
|
|
||||||
|
@@ foo bar
|
||||||
|
this is not foo
|
||||||
|
|
||||||
@@ layout
|
@@ layout
|
||||||
X
|
X
|
||||||
= yield
|
= yield
|
||||||
|
|
Loading…
Reference in New Issue