pakyow-presenter/lib/presenter/presenter.rb in pakyow-presenter-0.7.0 vs pakyow-presenter/lib/presenter/presenter.rb in pakyow-presenter-0.7.1

- old
+ new

@@ -126,11 +126,12 @@ # Call as part of View DSL for DOM manipulation # def with_container(container, &block) - ViewContext.new(self.view.find("##{container}").first).instance_eval(&block) + v = self.view.find("##{container}").first + ViewContext.new(v).instance_exec(v, &block) end # # Used by LazyView # @@ -164,22 +165,21 @@ else v_p = @request && @request.working_path end return unless v_p + return unless view_info = @view_lookup_store.view_info(v_p) + @root_path ||= view_info[:root_view] + if Configuration::Base.presenter.view_caching - r_v = @populated_root_view_cache[v_p] - if r_v then + r_v = @populated_root_view_cache.get([v_p, @root_path]) { + populate_view(LazyView.new(@root_path, true), view_info[:views]) + } @root_view = r_v.dup @presented = true - end else - return unless view_info = @view_lookup_store.view_info(v_p) - @root_path ||= view_info[:root_view] - @root_view = LazyView.new(@root_path, true) - views = view_info[:views] - populate_view(self.view, views) + @root_view = populate_view(LazyView.new(@root_path, true), view_info[:views]) @presented = true end end def restful_view_path(restful_info) @@ -196,16 +196,17 @@ @populated_root_view_cache = build_root_view_cache(@view_lookup_store.view_info) end end def build_root_view_cache(view_info) - r_v_c = {} + cache = Pakyow::Cache.new view_info.each{|dir,info| r_v = LazyView.new(info[:root_view], true) populate_view(r_v, info[:views]) - r_v_c[dir] = r_v + key = [dir, info[:root_view]] + cache.put(key, r_v) } - r_v_c + cache end # populates the top_view using view_store data by recursively building # and substituting in child views named in the structure def populate_view(top_view, views)