Class: Nanoc::MutableItemCollectionView

Inherits:
MutableIdentifiableCollectionView show all
Defined in:
lib/nanoc/base/views/mutable_item_collection_view.rb

Instance Method Summary collapse

Methods inherited from MutableIdentifiableCollectionView

#delete_if

Methods inherited from IdentifiableCollectionView

#[], #each, #find_all, #size

Methods inherited from View

#frozen?, #inspect

Instance Method Details

#create(content, attributes, identifier, binary: false, filename: nil) ⇒ self

Creates a new item and adds it to the site’s collection of items.

Parameters:

  • content (String)

    The uncompiled item content (if it is a textual item) or the path to the filename containing the content (if it is a binary item).

  • attributes (Hash)

    A hash containing this item’s attributes.

  • identifier (Nanoc::Identifier, String)

    This item’s identifier.

  • binary (Boolean)

    Whether or not this item is binary

  • filename (String)

    Absolute path to the file containing this content (if any)

Returns:

  • (self)


26
27
28
29
30
# File 'lib/nanoc/base/views/mutable_item_collection_view.rb', line 26

def create(content, attributes, identifier, binary: false, filename: nil)
  content = Nanoc::Int::Content.create(content, binary: binary, filename: filename)
  @objects = @objects.add(Nanoc::Int::Item.new(content, attributes, identifier))
  self
end