Deprecate use_in_file_templates!

Use enable :inline_templates instead
This commit is contained in:
Simon Rozet 2009-12-19 02:07:01 +01:00
parent 0067232e1f
commit 3ef8eedef2
3 changed files with 13 additions and 7 deletions

View File

@ -219,7 +219,7 @@ Or, specify an explicit Hash of local variables:
This is typically used when rendering templates as partials from within
other templates.
=== In-file Templates
=== Inline Templates
Templates may be defined at the end of the source file:
@ -239,9 +239,9 @@ Templates may be defined at the end of the source file:
@@ index
%div.title Hello world!!!!!
NOTE: In-file templates defined in the source file that requires sinatra
are automatically loaded. Call the <tt>use_in_file_templates!</tt>
method explicitly if you have in-file templates in other source files.
NOTE: Inline templates defined in the source file that requires sinatra
are automatically loaded. Call `enable :inline_templates` explicitly if you
have inline templates in other source files.
=== Named Templates

View File

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

View File

@ -720,10 +720,16 @@ module Sinatra
template name, &block
end
def use_in_file_templates!(file=nil)
warn "use_in_file_templates! is deprecated; " \
"use enable :inline_templates instead"
set :inline_templates, file
end
# Load embeded templates from the file; uses the caller's __FILE__
# when no file is specified.
def use_in_file_templates!(file=nil)
file ||= caller_files.first
def inline_templates=(file=nil)
file = (file.nil? || file == true) ? caller_files.first : file
begin
app, data =