From 7f2b234ffee4115c6608aac2c0412da9e22aad42 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Sun, 19 Sep 2010 13:26:26 +0200 Subject: [PATCH] Allow spaces in inline template names (still ignoring trailing spaces). --- lib/sinatra/base.rb | 2 +- test/templates_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 007c6a3a..71a39580 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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 diff --git a/test/templates_test.rb b/test/templates_test.rb index a32277f3..3eb7fd34 100644 --- a/test/templates_test.rb +++ b/test/templates_test.rb @@ -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