Sha256: fb1c8f65aeab5e817a4479ada33619ad3ab297a14efcba8c7fe8e12bfce9be36

Contents?: true

Size: 932 Bytes

Versions: 35

Compression:

Stored size: 932 Bytes

Contents

module Admin::RegionsHelper
  def render_region(region, options={}, &block)
    lazy_initialize_region_set
    default_partials = Radiant::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
    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

35 entries across 35 versions & 3 rubygems

Version Path
radiant-1.1.4 app/helpers/admin/regions_helper.rb
radiant-1.1.3 app/helpers/admin/regions_helper.rb
radiant-1.1.2 app/helpers/admin/regions_helper.rb
radiant-1.1.1 app/helpers/admin/regions_helper.rb
radiant-1.1.0 app/helpers/admin/regions_helper.rb
radiant-1.1.0.rc1 app/helpers/admin/regions_helper.rb
radiant-1.1.0.beta app/helpers/admin/regions_helper.rb
radiant-1.0.1 app/helpers/admin/regions_helper.rb
radiant-1.1.0.alpha app/helpers/admin/regions_helper.rb
radiant-1.0.0 app/helpers/admin/regions_helper.rb
radiant-1.0.0.rc5 app/helpers/admin/regions_helper.rb
radiant-1.0.0.rc4 app/helpers/admin/regions_helper.rb
radiant-1.0.0.rc3 app/helpers/admin/regions_helper.rb
radiant-1.0.0.rc2 app/helpers/admin/regions_helper.rb
radiant-1.0.0.rc1 app/helpers/admin/regions_helper.rb
radiantcms-couchrest_model-0.2.4 app/helpers/admin/regions_helper.rb
radiantcms-couchrest_model-0.2.2 app/helpers/admin/regions_helper.rb
radiantcms-couchrest_model-0.2.1 app/helpers/admin/regions_helper.rb
radiantcms-couchrest_model-0.2 app/helpers/admin/regions_helper.rb
radiantcms-couchrest_model-0.1.9 app/helpers/admin/regions_helper.rb