File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,18 @@ def container(name)
2121 end
2222 end
2323
24+ # Determine if a given container has any blocks within it. Useful for determine if markup should be conditionally included
25+ # when a block is present, but not shown if no block was added. For example:
26+ #
27+ # <% unless container_has_block? :sidebar %>
28+ # <div id="sidebar">
29+ # <%= container :sidebar %>
30+ # </div>
31+ # <% end %>
32+ #
33+ # @param [Symbol] name The name of the container to check
34+ # @param [Proc] block
35+ # @return [Boolean] True if the container has one or more blocks, or if we are in edit mode. False otherwise.
2436 def container_has_block? ( name , &block )
2537 has_block = ( @mode == "edit" ) || current_page . connectable_count_for_container ( name ) > 0
2638 logger . info "mode = #{ @mode } , has_block = #{ has_block } "
You can’t perform that action at this time.
0 commit comments