Class: Lifer::Builder::HTML::FromLiquid::Drops::TagDrop

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

Overview

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

Examples:

Usage

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lifer_tag) ⇒ TagDrop

Returns a new instance of TagDrop.



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

def initialize(lifer_tag) = (@lifer_tag = lifer_tag)

Instance Attribute Details

#lifer_tagObject

Returns the value of attribute lifer_tag.



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

def lifer_tag
  @lifer_tag
end

Instance Method Details

#entriesArray<EntryDrop>

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

{% for entry in tags..entries %}
  {{ entry.title }}
{% endfor %}

Returns:



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

def entries
  @entries ||= lifer_tag.entries.map { |lifer_entry|
    EntryDrop.new lifer_entry,
      collection: CollectionDrop.new(lifer_entry.collection),
      tags: lifer_entry.tags.map { TagDrop.new _1 }
  }
end

#layout_fileString

The tag's layout file path.

Returns:

  • (String)

    The path to the layout file.



40
# File 'lib/lifer/builder/html/from_liquid/drops/tag_drop.rb', line 40

def layout_file = (@lifer_tag.layout_file)

#nameSymbol

The tag name.

Returns:

  • (Symbol)


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

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