Class: Integral::PartialListItemRenderer

Inherits:
ListItemRenderer show all
Defined in:
lib/integral/partial_list_item_renderer.rb

Overview

Allow list items to be renderered through a partial

Instance Attribute Summary

Attributes inherited from ListItemRenderer

#list_item, #opts

Instance Method Summary collapse

Methods inherited from ListItemRenderer

#description, #fallback_image_url, #image, #image_url, #item_options, #non_object_image, #non_object_image_url, #object_data, #object_image_url, #render, render, #render_children, #subtitle, #target, #title, #title_required?, #type_for_dropdown, #url, #video?

Constructor Details

#initialize(list_item, opts = {}) ⇒ PartialListItemRenderer

Returns a new instance of PartialListItemRenderer.



4
5
6
7
8
# File 'lib/integral/partial_list_item_renderer.rb', line 4

def initialize(list_item, opts = {})
  super

  raise_if_partial_path_missing
end

Instance Method Details

#render_itemObject

Override Integral::ListItemRenderer#render_item



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/integral/partial_list_item_renderer.rb', line 11

def render_item
  partial_opts = {
    title: title,
    subtitle: subtitle,
    description: description,
    url: url,
    image: image,
    type: list_item.type,
    object: object_available? ? list_item.object.decorate : nil,
    renderer: self
  }

  controller.render partial: @opts[:partial_path], locals: partial_opts, layout: false
end