Sha256: 5738b5222b4b0e44a6624d9d2825d6bf3ca5535932e118e52b4bad90cdf9a8a5

Contents?: true

Size: 568 Bytes

Versions: 6

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

module EffectivePageSectionsHelper

  def effective_page_sections
    @_effective_page_sections ||= Effective::PageSection.all
  end

  def render_page_section(name, &block)
    raise('expected a name') unless name.present?

    name = name.to_s

    page_section = effective_page_sections.find { |ps| ps.name == name }
    raise("unable to find page section with name #{name}") unless page_section.present?

    if block_given?
      yield(page_section); nil
    else
      page_section.rich_text_body.to_s.html_safe
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
effective_pages-3.4.2 app/helpers/effective_page_sections_helper.rb
effective_pages-3.4.1 app/helpers/effective_page_sections_helper.rb
effective_pages-3.4.0 app/helpers/effective_page_sections_helper.rb
effective_pages-3.3.2 app/helpers/effective_page_sections_helper.rb
effective_pages-3.3.1 app/helpers/effective_page_sections_helper.rb
effective_pages-3.3.0 app/helpers/effective_page_sections_helper.rb