Sha256: a9994eb1ec8539488a78a4da08d08d55715cbed1932e875cc67aca46e73e5756

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

module BlockHelper

  def render_blocks(record, options = {})
    return if record.blank?

    begin
      block_layout = options[:block_layout].presence || BlockLayout.default_layout

      if block_layout.is_a?(Symbol)
        block_layout = BlockLayout.find_by_slug(block_layout)
      end

      collection = record.blocks(block_layout: block_layout).reject(&:hidden?)

      if collection.present?
        content_tag :div, class: "blocks block-layout--#{block_layout.slug}" do
          render partial: 'blocks/show', collection: collection, as: 'block'
        end
      end
    rescue Exception => e
      forest_admin_error(e)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forest_cms-0.98.1 app/helpers/block_helper.rb