closes #308 - Depricate use_in_file_templates! in favor of slurp_file_templates

This commit is contained in:
Blake Mizerany 2009-12-17 18:25:18 -08:00
parent 7c253c2f80
commit 056bd7bb77
3 changed files with 7 additions and 7 deletions

View File

@ -4,4 +4,4 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
require 'sinatra/base' require 'sinatra/base'
require 'sinatra/main' require 'sinatra/main'
use_in_file_templates! slup_file_templates

View File

@ -722,7 +722,7 @@ module Sinatra
# Load embeded templates from the file; uses the caller's __FILE__ # Load embeded templates from the file; uses the caller's __FILE__
# when no file is specified. # when no file is specified.
def use_in_file_templates!(file=nil) def slup_file_templates(file=nil)
file ||= caller_files.first file ||= caller_files.first
begin begin
@ -1119,7 +1119,7 @@ module Sinatra
delegate :get, :put, :post, :delete, :head, :template, :layout, delegate :get, :put, :post, :delete, :head, :template, :layout,
:before, :after, :error, :not_found, :configure, :set, :mime_type, :before, :after, :error, :not_found, :configure, :set, :mime_type,
:enable, :disable, :use, :development?, :test?, :enable, :disable, :use, :development?, :test?,
:production?, :use_in_file_templates!, :helpers :production?, :slup_file_templates, :helpers
end end
# Create a new Sinatra application. The block is evaluated in the new app's # Create a new Sinatra application. The block is evaluated in the new app's

View File

@ -76,9 +76,9 @@ class TemplatesTest < Test::Unit::TestCase
assert_equal "Layout 3!\nHello World!\n", body assert_equal "Layout 3!\nHello World!\n", body
end end
it 'loads templates from source file with use_in_file_templates!' do it 'loads templates from source file with slup_file_templates' do
mock_app { mock_app {
use_in_file_templates! slup_file_templates
} }
assert_equal "this is foo\n\n", @app.templates[:foo][0] assert_equal "this is foo\n\n", @app.templates[:foo][0]
assert_equal "X\n= yield\nX\n", @app.templates[:layout][0] assert_equal "X\n= yield\nX\n", @app.templates[:layout][0]
@ -90,10 +90,10 @@ class TemplatesTest < Test::Unit::TestCase
assert_equal "from another views directory\n", body assert_equal "from another views directory\n", body
end end
test 'use_in_file_templates simply ignores IO errors' do test 'slup_file_templates simply ignores IO errors' do
assert_nothing_raised { assert_nothing_raised {
mock_app { mock_app {
use_in_file_templates!('/foo/bar') slup_file_templates('/foo/bar')
} }
} }