pakyow-presenter/lib/presenter/presenter.rb in pakyow-presenter-0.8.0 vs pakyow-presenter/lib/presenter/presenter.rb in pakyow-presenter-0.9.0

- old
+ new

@@ -79,11 +79,11 @@ def prepare_with_context(context) @context = context if @context.request.has_route_vars? - @path = Utils::String.remove_route_vars(@context.request.route_path) + @path = String.remove_route_vars(@context.request.route_path) else @path = @context.request.path end setup @@ -95,25 +95,19 @@ false end def content to_present = view - view.is_a?(ViewComposer) ? view.composed.to_html : view.to_html + to_present.is_a?(ViewComposer) ? to_present.composed.to_html : to_present.to_html end def view - view = @composer || @view - raise MissingView if view.nil? - - view.context = @context - - return view + @composer || @view || raise(MissingView) end def view=(view) @view = view - @view.context = @context # setting a view means we no longer use/need the composer @composer = nil end @@ -172,19 +166,26 @@ @view, @composer = nil self.store = :default end def setup_for_path(path, explicit = false) - @composer = store.composer(path) - @path = path - rescue MissingView => e # catches no view path error + @view_stores.each do |name, store| + begin + @composer = store.composer(path) + @path = path + return + rescue MissingView + end + end + + e = MissingView.new("No view at path '#{path}'") explicit ? raise(e) : Pakyow.logger.debug(e.message) end def load_views @view_stores = {} - Config::Presenter.view_stores.each_pair {|name, path| + Pakyow::Config.presenter.view_stores.each_pair {|name, path| @view_stores[name] = ViewStore.new(path, name) } end def load_bindings