Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow spaces after inline template names. Fixes GH #61.

  • Loading branch information...
commit 3475f505caa34aceee6bb576fc91d532eb22160c 1 parent 68d2d7b
@rkh authored
Showing with 9 additions and 1 deletion.
  1. +1 −1  lib/sinatra/base.rb
  2. +8 −0 test/templates_test.rb
View
2  lib/sinatra/base.rb
@@ -824,7 +824,7 @@ def inline_templates=(file=nil)
template = nil
data.each_line do |line|
lines += 1
- if line =~ /^@@\s*(.*)/
+ if line =~ /^@@\s*(\S*)/
template = ''
templates[$1.to_sym] = [template, file, lines]
elsif template
View
8 test/templates_test.rb
@@ -84,6 +84,11 @@ def with_default_layout
assert_equal "X\n= yield\nX\n", @app.templates[:layout][0]
end
+ 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]
+ end
+
it 'loads templates from given source file' do
mock_app { set :inline_templates, __FILE__ }
assert_equal "this is foo\n\n", @app.templates[:foo][0]
@@ -154,6 +159,9 @@ def with_default_layout
@@ foo
this is foo
+@@ bar
+There's a space after 'bar'!
+
@@ layout
X
= yield
Please sign in to comment.
Something went wrong with that request. Please try again.