mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
take views into account for template caching, fixes #631
This commit is contained in:
parent
2d687ab6c3
commit
0e1585ceae
3 changed files with 11 additions and 2 deletions
2
CHANGES
2
CHANGES
|
@ -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)
|
||||
|
|
|
@ -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?
|
||||
|
||||
|
|
|
@ -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 %>' }
|
||||
|
|
Loading…
Add table
Reference in a new issue