Skip to content

Commit

Permalink
reload_templates setting; on by default in :development [sinatra#321]
Browse files Browse the repository at this point in the history
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
rtomayko committed Jan 28, 2010
1 parent 0781c28 commit f889c75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/sinatra/base.rb
Expand Up @@ -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) }
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f889c75

Please sign in to comment.