diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/paths.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/renderable.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 18 |
3 files changed, 20 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/paths.rb b/actionpack/lib/action_view/paths.rb index f01ed9e6e0..ecb6103ade 100644 --- a/actionpack/lib/action_view/paths.rb +++ b/actionpack/lib/action_view/paths.rb @@ -102,7 +102,7 @@ module ActionView #:nodoc: @paths = {} templates_in_path do |template| - template.freeze + template.load! @paths[template.path] = template @paths[template.path_without_extension] ||= template end diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb index c04399f2c9..7258ad04bf 100644 --- a/actionpack/lib/action_view/renderable.rb +++ b/actionpack/lib/action_view/renderable.rb @@ -96,7 +96,7 @@ module ActionView # The template will be compiled if the file has not been compiled yet, or # if local_assigns has a new key, which isn't supported by the compiled code yet. def recompile?(symbol) - !(frozen? && Base::CompiledTemplates.method_defined?(symbol)) + !Base::CompiledTemplates.method_defined?(symbol) || !loaded? end end end diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index ca82454c0b..b486392ac4 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -57,6 +57,11 @@ module ActionView #:nodoc: end memoize :relative_path + def mtime + File.mtime(filename) + end + memoize :mtime + def source File.read(filename) end @@ -79,6 +84,19 @@ module ActionView #:nodoc: end end + def stale? + File.mtime(filename) > mtime + end + + def loaded? + @loaded + end + + def load! + @loaded = true + freeze + end + private def valid_extension?(extension) Template.template_handler_extensions.include?(extension) |