Sha256: 91abbc00844fcc4934a3c581fc6693e082acc2589beb4d053dc4fd90d5183b28

Contents?: true

Size: 974 Bytes

Versions: 65

Compression:

Stored size: 974 Bytes

Contents

module Admin::RegionsHelper
  def render_region(region, options = {}, &block)
    lazy_initialize_region_set
    default_partials = TrustyCms::AdminUI::RegionPartials.new(self)
    if block_given?
      block.call(default_partials)
      (options[:locals] ||= {}).merge!(defaults: default_partials)
    end
    output = @region_set[region].compact.map do |partial|
      begin
        render options.merge(partial: partial)
      rescue ::ActionView::MissingTemplate # couldn't find template
        default_partials[partial]
      rescue ::ActionView::TemplateError => e # error in template
        raise e
      end
    end.join.html_safe
    Rails.logger.error(output)
    block_given? ? concat(output) : output
  end

  def lazy_initialize_region_set
    unless @region_set
      @controller_name ||= @_controller.controller_name
      @template_name ||= @_controller.template_name
      @region_set = admin.send(@controller_name).send(@template_name)
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
trusty-cms-6.2.2.1 app/helpers/admin/regions_helper.rb
trusty-cms-6.2.0 app/helpers/admin/regions_helper.rb
trusty-cms-6.1.2 app/helpers/admin/regions_helper.rb
trusty-cms-6.1.1 app/helpers/admin/regions_helper.rb
trusty-cms-6.0.5 app/helpers/admin/regions_helper.rb
trusty-cms-6.0.4 app/helpers/admin/regions_helper.rb
trusty-cms-6.0.3 app/helpers/admin/regions_helper.rb
trusty-cms-6.0.2 app/helpers/admin/regions_helper.rb
trusty-cms-6.0.1 app/helpers/admin/regions_helper.rb
trusty-cms-5.6.1 app/helpers/admin/regions_helper.rb
trusty-cms-6.0.0 app/helpers/admin/regions_helper.rb
trusty-cms-5.6.0 app/helpers/admin/regions_helper.rb
trusty-cms-5.5.9 app/helpers/admin/regions_helper.rb
trusty-cms-5.5.8 app/helpers/admin/regions_helper.rb
trusty-cms-5.5.7 app/helpers/admin/regions_helper.rb
trusty-cms-5.5.6 app/helpers/admin/regions_helper.rb
trusty-cms-5.5.5.1 app/helpers/admin/regions_helper.rb
trusty-cms-5.5.1 app/helpers/admin/regions_helper.rb
trusty-cms-5.5 app/helpers/admin/regions_helper.rb
trusty-cms-5.4.4 app/helpers/admin/regions_helper.rb