Sha256: 81fa29eb0bb1fe928423fb4936eba6b0e89bcfde4a4a1d08e657be6053ce90d6

Contents?: true

Size: 550 Bytes

Versions: 37

Compression:

Stored size: 550 Bytes

Contents

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

37 entries across 37 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.8 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.7 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.6 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.5 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.4 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.3 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.2 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.1 lib/nanoc/helpers/child_parent.rb
nanoc-4.7.0 lib/nanoc/helpers/child_parent.rb
nanoc-4.6.4 lib/nanoc/helpers/child_parent.rb
nanoc-4.6.3 lib/nanoc/helpers/child_parent.rb
nanoc-4.6.2 lib/nanoc/helpers/child_parent.rb
nanoc-4.6.1 lib/nanoc/helpers/child_parent.rb
nanoc-4.6.0 lib/nanoc/helpers/child_parent.rb
nanoc-4.5.4 lib/nanoc/helpers/child_parent.rb
nanoc-4.5.3 lib/nanoc/helpers/child_parent.rb
nanoc-4.5.2 lib/nanoc/helpers/child_parent.rb
nanoc-4.5.1 lib/nanoc/helpers/child_parent.rb
nanoc-4.5.0 lib/nanoc/helpers/child_parent.rb