lib/roda/plugins/content_for.rb in roda-2.28.0 vs lib/roda/plugins/content_for.rb in roda-2.29.0

- old
+ new

@@ -42,11 +42,11 @@ # Configure whether to append or overwrite if content_for # is called multiple times to set data. Overwrite is default, use # the :append option to append. def self.configure(app, opts = {}) - app.opts[:append_content_for] = opts.fetch(:append, false) + app.opts[:append_content_for] = opts.fetch(:append, nil) end module InstanceMethods # If called with a block, store content enclosed by block # under the given key. If called without a block, retrieve @@ -69,9 +69,12 @@ @_content_for ||= {} if append (@_content_for[key] ||= []) << value else + if @_content_for[key] && append.nil? + RodaPlugins.warn "Attempt to set content_for with same key. This currently overwrites the existing content_for for #{key}. In Roda 3, it will start appending to the existing content_for by default. Use the :append => false option to the content_for plugin to keep the existing behavior." + end @_content_for[key] = value end elsif @_content_for && (value = @_content_for[key]) if append value = value.join