Deprecate use_in_file_templates!
Use enable :inline_templates instead
This commit is contained in:
parent
0067232e1f
commit
3ef8eedef2
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 =
|
||||||
|
|
Loading…
Reference in New Issue