Sha256: 656eac28193cbded201b49f18060335a9aa3a5367f0a9c3783c61312313a3a9e

Contents?: true

Size: 583 Bytes

Versions: 6

Compression:

Stored size: 583 Bytes

Contents

# frozen_string_literal: true

module Nanoc::Helpers
  # @see https://nanoc.app/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

6 entries across 6 versions & 1 rubygems

Version Path
nanoc-4.13.3 lib/nanoc/helpers/child_parent.rb
nanoc-4.13.2 lib/nanoc/helpers/child_parent.rb
nanoc-4.13.1 lib/nanoc/helpers/child_parent.rb
nanoc-4.13.0 lib/nanoc/helpers/child_parent.rb
nanoc-4.12.21 lib/nanoc/helpers/child_parent.rb
nanoc-4.12.20 lib/nanoc/helpers/child_parent.rb