closes #308 - Depricate use_in_file_templates! in favor of slurp_file_templates
This commit is contained in:
parent
7c253c2f80
commit
056bd7bb77
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue