Class: Lifer::Builder::HTML::FromLiquid::Drops::CollectionDrop

Inherits:
Liquid::Drop
  • Object
show all
Defined in:
lib/lifer/builder/html/from_liquid/drops/collection_drop.rb

Overview

This drop allows users to access Lifer collection information from within Liquid templates.

Examples:

Usage

{{ collection.name }}
{% for entries in collection.entries %}
  {{ entry.title }}
{% endfor %}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lifer_collection) ⇒ CollectionDrop

Returns a new instance of CollectionDrop.



14
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 14

def initialize(lifer_collection) = (@lifer_collection = lifer_collection)

Instance Attribute Details

#lifer_collectionObject

Returns the value of attribute lifer_collection.



12
13
14
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 12

def lifer_collection
  @lifer_collection
end

Instance Method Details

#entriesArray<EntryDrop>

Gets all entries in a collection and converts them to entry drops that can be accessed in Liquid templates. Example:

{% for entry in collections.root.entries %}
  {{ entry.title }}
{% endfor %}

Returns:



29
30
31
32
33
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 29

def entries
  @entries ||= lifer_collection.entries.map {
    EntryDrop.new _1, collection: self, tags: _1.tags
  }
end

#layout_fileString

The collection’s layout file path.

Returns:

  • (String)

    The path to the layout file.



38
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 38

def layout_file = (@lifer_collection.layout_file)

#nameSymbol

The collection name.

Returns:

  • (Symbol)


19
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 19

def name = (@name ||= lifer_collection.name)