Class: Ecm::Galleries::GalleriesHelper

Inherits:
Rao::ViewHelper::Base
  • Object
show all
Defined in:
app/view_helpers/ecm/galleries/galleries_helper.rb

Overview

Usage:

# app/controllers/application_vontroller.rb
class ApplicationController < ActionController::Base
  view_helper Ecm::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 Ecm::Galleries::Configuration.galleries_helper_render_default_options. You can set this option in the initializer.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ GalleriesHelper

Returns a new instance of GalleriesHelper.



18
19
20
# File 'app/view_helpers/ecm/galleries/galleries_helper.rb', line 18

def initialize(context)
  @context = context
end

Instance Method Details

#render(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'app/view_helpers/ecm/galleries/galleries_helper.rb', line 22

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