take views into account for template caching, fixes #631

This commit is contained in:
Konstantin Haase 2013-02-26 12:49:39 +11:00
parent 2d687ab6c3
commit 0e1585ceae
3 changed files with 11 additions and 2 deletions

View File

@ -77,6 +77,8 @@
* Fix mixed indentation for private methods. (Robin Dupret)
* Take views option into account for template caching. (Konstantin Haase)
= 1.3.5 / 2013-02-25
* Fix for RubyGems 2.0 (Uchio KONDO)

View File

@ -782,7 +782,7 @@ module Sinatra
def compile_template(engine, data, options, views)
eat_errors = options.delete :eat_errors
template_cache.fetch engine, data, options do
template_cache.fetch engine, data, options, views do
template = Tilt[engine]
raise "Template engine not found: #{engine}" if template.nil?

View File

@ -196,11 +196,18 @@ class TemplatesTest < Test::Unit::TestCase
end
it 'loads templates from specified views directory' do
render_app { render( :test, :hello, :views => settings.views + '/foo') }
render_app { render(:test, :hello, :views => settings.views + '/foo') }
assert_equal "from another views directory\n", body
end
it 'takes views directory into consideration for caching' do
render_app do
render(:test, :hello) + render(:test, :hello, :views => settings.views + '/foo')
end
assert_equal "Hello World!\nfrom another views directory\n", body
end
it 'passes locals to the layout' do
mock_app do
template(:my_layout) { 'Hello <%= name %>!<%= yield %>' }