Module: Nanoc::Helpers::ChildParent

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

Overview

Instance Method Summary collapse

Instance Method Details

#children_of(item) ⇒ Object



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

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



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

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