From 3ef8eedef257b513f531dd48bfedcbc8df8a622b Mon Sep 17 00:00:00 2001 From: Simon Rozet Date: Sat, 19 Dec 2009 02:07:01 +0100 Subject: [PATCH] Deprecate use_in_file_templates! Use enable :inline_templates instead --- README.rdoc | 8 ++++---- lib/sinatra.rb | 2 +- lib/sinatra/base.rb | 10 ++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.rdoc b/README.rdoc index b8543c79..0a92a1a5 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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 use_in_file_templates! -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 diff --git a/lib/sinatra.rb b/lib/sinatra.rb index ce3ad6a4..71b122d1 100644 --- a/lib/sinatra.rb +++ b/lib/sinatra.rb @@ -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 diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 780b8740..47cf3bd6 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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 =