lib/hanami/extensions/view/context.rb in hanami-2.1.0.rc2 vs lib/hanami/extensions/view/context.rb in hanami-2.1.0.rc3

- old
+ new

@@ -141,11 +141,18 @@ # # @api public # @since 2.1.0 def assets unless @assets - raise Hanami::ComponentLoadError, "the hanami-assets gem is required to access assets" + msg = + if Hanami.bundled?("hanami-assets") + "Have you put files into your assets directory?" + else + "The hanami-assets gem is required to access assets." + end + + raise Hanami::ComponentLoadError, "Assets not available. #{msg}" end @assets end @@ -157,11 +164,11 @@ # # @api public # @since 2.1.0 def request unless @request - raise Hanami::ComponentLoadError, "only views rendered from Hanami::Action instances have a request" + raise Hanami::ComponentLoadError, "Request not available. Only views rendered from Hanami::Action instances have a request." end @request end @@ -192,11 +199,11 @@ # # @example # content_for(:page_title, "Hello world") # # @example In a template - # <% content_for :page_title do %> + # <%= content_for :page_title do %> # <h1>Hello world</h1> # <% end %> # # @overload content_for(key) # Returns the previously stored content for the given key. @@ -209,11 +216,13 @@ # @api public # @since 2.1.0 def content_for(key, value = nil) if block_given? @content_for[key] = yield + nil elsif value @content_for[key] = value + nil else @content_for[key] end end