Sha256: 41ae17d3c3ff531107a16605ba810ef69553e3e8fe5249a06e9d81ffa2a3068b

Contents?: true

Size: 1.05 KB

Versions: 65

Compression:

Stored size: 1.05 KB

Contents

module RedmineExtensions
  module RenderingHelper

    def render_with_fallback(*attrs)
      raise 'Missing an options argument' unless attrs.last.is_a?(Hash)
      options = attrs.last
      raise 'Missing an fallback prefixes' unless options[:prefixes]
      partial = options[:partial] || attrs.first
      prefixes = options.delete(:prefixes)

      prefixes = prefixes.model if prefixes.is_a?(BasePresenter)
      prefixes = prefixes.hiearchy.map{|klass| klass.underscore.pluralize } if prefixes.is_a?(ActiveRecord::Base)

      prefixes.each do |prefix|
        if lookup_context.template_exists?(partial, prefix, true)
          partial.prepend("#{prefix}/")
          return render(*attrs)
        end
      end
      partial.prepend("#{prefixes.last}/")
      render(*attrs)
    end

    def query_outputs(presenter_or_query, options={})
      presenter = present(presenter_or_query, options) rescue RedmineExtensions::BasePresenter.new(presenter_or_query, self, options)
      RedmineExtensions::EasyQueryHelpers::Outputs.new(presenter, self)
    end
  end
end

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
redmine_extensions-1.2.0 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-1.1.2 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-1.1.1 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-1.1.0 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-1.0.0 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.6.3 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.6.2 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.6.1 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.6.0 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.4.5 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.5.1 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.4.4 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.4.3 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.4.1 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.4.0 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.4.0.beta app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.3.11 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.3.10 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.3.9 app/helpers/redmine_extensions/rendering_helper.rb
redmine_extensions-0.3.8 app/helpers/redmine_extensions/rendering_helper.rb