Sha256: 0b2ede6ab5372b0d24a123020fd13978d632978340efc1779213cb7d93e92103

Contents?: true

Size: 582 Bytes

Versions: 41

Compression:

Stored size: 582 Bytes

Contents

# frozen_string_literal: true

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

41 entries across 41 versions & 1 rubygems

Version Path
nanoc-4.11.23 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.22 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.21 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.20 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.19 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.18 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.17 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.16 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.15 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.14 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.13 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.12 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.11 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.10 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.9 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.8 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.7 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.6 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.5 lib/nanoc/helpers/child_parent.rb
nanoc-4.11.4 lib/nanoc/helpers/child_parent.rb