Module: Cocooned::Helpers::Containers

Defined in:
lib/cocooned/helpers/containers.rb

Overview

Cocooned containers helpers output container or item wrappers as expected by the JavaScript companion package.

Instance Method Summary collapse

Instance Method Details

#cocooned_container(*args) ⇒ Object

Wrap content with the expected markup for a Cocooned container.

This is a wrapper around ‘ActionView::Base#content_tag` to automatically add default classes and data-attributes that define a Cocooned container.

Signatures

cocooned_container(*arguments, **options) do
  # Container content
end

Parameters

cocooned_container supports following options:

  • :limit [Integer] Enable the limit plugin and set the accepted maximum number of items

  • :reorderable [Boolean|Hash] Enable the reorderable plugin. When a boolean, use plugin’s default. You can also pass a Hash with explicit options (ex: ‘{ startAt: 1 }`).

Any other argument or option supported by ‘ActionView::Base#content_tag` will be forwarded.



32
33
34
35
36
37
# File 'lib/cocooned/helpers/containers.rb', line 32

def cocooned_container(*args, &)
  options = args.extract_options!.dup
  name = args.shift || :div

  (name, *args, **cocooned_container_options(options), &)
end

#cocooned_item(*args) ⇒ Object

Wrap content with the expected markup for a Cocooned item.

This is a wrapper around ‘ActionView::Base#content_tag` to automatically add default classes and data-attributes that define a Cocooned item.

Signatures

cocooned_item(*arguments, **options) do
  # Item content
end

Parameters

Any argument or option supported by ‘ActionView::Base#content_tag` will be forwarded.



54
55
56
57
58
59
# File 'lib/cocooned/helpers/containers.rb', line 54

def cocooned_item(*args, &)
  options = args.extract_options!.dup
  name = args.shift || :div

  (name, *args, **cocooned_item_options(options), &)
end