Permalink
Browse files

reload_templates setting; on by default in :development [#321]

Enabling the reload_templates setting causes template files to be
reread from disk and recompiled on each request. It's disabled by
default in all environments except for development.
  • Loading branch information...
1 parent 0781c28 commit f889c75cd4ac425f8b3041fc6ab75c01b7a9277b @rtomayko rtomayko committed Jan 28, 2010
Showing with 7 additions and 2 deletions.
  1. +4 −1 CHANGES
  2. +3 −1 lib/sinatra/base.rb
View
5 CHANGES
@@ -9,9 +9,12 @@
template backtraces, and support for new template engines, like
mustache and liquid.
+ * New boolean 'reload_templates' setting controls whether template files
+ are reread from disk and recompiled on each request. Template read/compile
+ is cached by default in all environments except development.
+
* New 'settings' method gives access to options in both class and request
scopes. This replaces the 'options' method.
-
* New 'erubis' helper method for rendering Erubis templates.
* New 'expires' helper method is like cache_control but takes an
View
4 lib/sinatra/base.rb
@@ -387,6 +387,7 @@ def call!(env)
@request = Request.new(env)
@response = Response.new
@params = indifferent_params(@request.params)
+ @template_cache.clear if settings.reload_templates
invoke { dispatch! }
invoke { error_block!(response.status) }
@@ -1039,8 +1040,9 @@ def caller_locations
set :app_file, nil
set :root, Proc.new { app_file && File.expand_path(File.dirname(app_file)) }
- set :views, Proc.new { root && File.join(root, 'views') }
set :public, Proc.new { root && File.join(root, 'public') }
+ set :views, Proc.new { root && File.join(root, 'views') }
+ set :reload_templates, Proc.new { !development? }
set :lock, false
error ::Exception do

0 comments on commit f889c75

Please sign in to comment.