lib/godmin/helpers/application.rb in godmin-1.5.0 vs lib/godmin/helpers/application.rb in godmin-2.0.0
- old
+ new
@@ -2,20 +2,20 @@
module Helpers
module Application
# Renders the provided partial with locals if it exists, otherwise
# yields the given block. The lookup context call is cached for
# each partial.
- def partial_override(partial, locals = {})
+ def partial_override(partial, locals = {}, &block)
@_partial_override ||= {}
- if @_partial_override[partial].nil?
+ unless @_partial_override.key?(partial)
@_partial_override[partial] = lookup_context.exists?(partial, nil, true)
end
if @_partial_override[partial]
render partial: partial, locals: locals
else
- yield
+ capture(&block)
end
end
# Wraps the policy helper so that it is always accessible, even when
# authorization is not enabled. When that is the case, it returns a