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 This is typically used when rendering templates as partials from within
other templates. other templates.
=== In-file Templates === Inline Templates
Templates may be defined at the end of the source file: 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 @@ index
%div.title Hello world!!!!! %div.title Hello world!!!!!
NOTE: In-file templates defined in the source file that requires sinatra NOTE: Inline templates defined in the source file that requires sinatra
are automatically loaded. Call the <tt>use_in_file_templates!</tt> are automatically loaded. Call `enable :inline_templates` explicitly if you
method explicitly if you have in-file templates in other source files. have inline templates in other source files.
=== Named Templates === Named Templates

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! enable :inline_templates

View File

@ -720,10 +720,16 @@ module Sinatra
template name, &block template name, &block
end 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__ # 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 inline_templates=(file=nil)
file ||= caller_files.first file = (file.nil? || file == true) ? caller_files.first : file
begin begin
app, data = app, data =