Class: Lifer::Builder::HTML::FromLiquid::Drops::CollectionDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lifer::Builder::HTML::FromLiquid::Drops::CollectionDrop
- 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.
Instance Attribute Summary collapse
-
#lifer_collection ⇒ Object
Returns the value of attribute lifer_collection.
Instance Method Summary collapse
-
#entries ⇒ Array<EntryDrop>
Gets all entries in a collection and converts them to entry drops that can be accessed in Liquid templates.
-
#initialize(lifer_collection) ⇒ CollectionDrop
constructor
A new instance of CollectionDrop.
-
#layout_file ⇒ String
The collection’s layout file path.
-
#name ⇒ Symbol
The collection name.
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_collection ⇒ Object
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
#entries ⇒ Array<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 %}
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. } end |
#layout_file ⇒ String
The collection’s layout file path.
38 |
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 38 def layout_file = (@lifer_collection.layout_file) |
#name ⇒ Symbol
The collection name.
19 |
# File 'lib/lifer/builder/html/from_liquid/drops/collection_drop.rb', line 19 def name = (@name ||= lifer_collection.name) |