Module: Nanoc::Helpers::ChildParent

Defined in:
lib/nanoc/helpers/child_parent.rb

Overview

Instance Method Summary collapse

Instance Method Details

#children_of(item) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/nanoc/helpers/child_parent.rb', line 15

def children_of(item)
  if item.identifier.legacy?
    item.children
  else
    pattern = item.identifier.without_ext + '/*'
    @items.find_all(pattern)
  end
end

#parent_of(item) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/nanoc/helpers/child_parent.rb', line 6

def parent_of(item)
  if item.identifier.legacy?
    item.parent
  else
    path_without_last_component = item.identifier.to_s.sub(/[^\/]+$/, '').chop
    @items[path_without_last_component + '.*']
  end
end