Sha256: 93150b00b59c4196d47c92996b93f59ee7c0dcfb0d70f894642d5dd86fdb7226
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 KB
Contents
# See dry_views/rails2_two for comments... this is the same logic applied to the older ActionView @_content_for chain module ActionView module Helpers module CaptureHelper def content_for_with_default(name, *args, &block) if content_check = content_for?(name) content_for_without_empty_check(name) unless content_check == :empty elsif block_given? content_for_without_empty_check(name, yield) else options = args.extract_options! if options.empty? content_for_without_empty_check(name, args.first) else render options end end end def content_for_with_empty_check(name, content = nil, &block) if content_for?(name) == :empty return nil else content_for_without_empty_check(name, content, &block) end end alias_method_chain :content_for, :empty_check def content_for_with_empty_check?(name) if @_content_for[name] == DryViews::EMPTY_CONTENT return :empty elsif content_for_without_empty_check?(name) return true else return false end end alias_method_chain :content_for?, :empty_check def no_content_for(name) @_content_for[name] << DryViews::EMPTY_CONTENT end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry_views-0.0.2 | lib/dry_views/rails3_zero.rb |
dry_views-0.0.1 | lib/dry_views/rails3_zero.rb |