Sha256: 762076ae07fd684d5a563176c315d41d97aecc6001dc0a99051cd37d87927d00

Contents?: true

Size: 1.34 KB

Versions: 39

Compression:

Stored size: 1.34 KB

Contents

module Cmor
  module Galleries
    # Usage:
    #
    #     # app/controllers/application_vontroller.rb
    #     class ApplicationController < ActionController::Base
    #       view_helper Cmor::Galleries::GalleriesHelper, as: :galleries_helper
    #       # ...
    #     end
    #
    #     # app/views/home/index.html.haml
    #     = galleries_helper(self).render(name: 'main', variant_options: { combine_options: { resize: "255x255^", extent: "255x255", gravity: "center"} }, show_details: true)
    #
    # Default options are taken from Cmor::Galleries::Configuration.galleries_helper_render_default_options.
    # You can set this option in the initializer.
    #
    class GalleriesHelper < Rao::ViewHelper::Base
      def initialize(context)
        @context = context
      end

      def render(options = {})
        options.reverse_merge!(Cmor::Galleries::Configuration.galleries_helper_render_default_options)
        
        name            = options.delete(:name)
        variant_options = options.delete(:variant_options)
        show_details    = options.delete(:show_details)
        
        resource = Cmor::Galleries::PictureGallery.where(name: name).first
        c.render partial: 'cmor/galleries/galleries_helper/render', locals: { resource: resource, variant_options: variant_options, show_details: show_details }
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
cmor_galleries-0.0.40.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.39.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.38.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.37.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.36.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.35.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.34.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.33.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.32.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.31.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.30.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.29.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.28.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.27.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.26.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.25.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.24.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.22.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.21.pre app/view_helpers/cmor/galleries/galleries_helper.rb
cmor_galleries-0.0.20.pre app/view_helpers/cmor/galleries/galleries_helper.rb