Sha256: f63b74f23ad457e79ae7f10b7974b56a0b20300b9c2c0ac61cd2004b967d5d75

Contents?: true

Size: 581 Bytes

Versions: 43

Compression:

Stored size: 581 Bytes

Contents

# frozen_string_literal: true

module Nanoc::Helpers
  # @see http://nanoc.ws/doc/reference/helpers/#childparent
  module ChildParent
    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

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

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
nanoc-4.7.12 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.11 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.10 lib/nanoc/helpers/child_parent.rb