make sure we check every alternative extension registered for a template engine, fixes #179.
This commit is contained in:
parent
227c9df27c
commit
5467056237
|
@ -508,13 +508,12 @@ module Sinatra
|
|||
template.new(path, line.to_i, options) { body }
|
||||
else
|
||||
found = false
|
||||
path = ::File.join(views, "#{data}.#{engine}")
|
||||
Tilt.mappings.each do |ext, klass|
|
||||
break if found = File.exists?(path)
|
||||
next unless klass == template
|
||||
path = ::File.join(views, "#{data}.#{ext}")
|
||||
break if found = File.exists?(path)
|
||||
end
|
||||
throw :layout_missing if eat_errors and !found
|
||||
throw :layout_missing if eat_errors and not found
|
||||
template.new(path, 1, options)
|
||||
end
|
||||
when data.is_a?(Proc) || data.is_a?(String)
|
||||
|
|
|
@ -223,6 +223,12 @@ class TemplatesTest < Test::Unit::TestCase
|
|||
end
|
||||
assert_equal "Hello <%= 'World' %>!", body
|
||||
end
|
||||
|
||||
it "is possible to register another template" do
|
||||
Tilt.register "html.erb", Tilt[:erb]
|
||||
render_app { render :erb, :calc }
|
||||
assert_equal '2', body
|
||||
end
|
||||
end
|
||||
|
||||
# __END__ : this is not the real end of the script.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<%= 1 + 1 %>
|
Loading…
Reference in New Issue