Class: Nanoc::Core::MutableItemCollectionView

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

Constant Summary

Constants inherited from IdentifiableCollectionView

IdentifiableCollectionView::NOTHING

Instance Method Summary collapse

Methods inherited from MutableIdentifiableCollectionView

#delete_if

Methods inherited from IdentifiableCollectionView

#[], #_unwrap, #each, #find_all, #initialize, #size, #where

Methods inherited from View

#_context, #_unwrap, #frozen?, #initialize, #inspect

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

This class inherits a constructor from Nanoc::Core::IdentifiableCollectionView

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::Core::Identifier, String)

    This item’s identifier.

  • binary (Boolean) (defaults to: false)

    Whether or not this item is binary

  • filename (String) (defaults to: nil)

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

Returns:

  • (self)


27
28
29
30
31
# File 'lib/nanoc/core/mutable_item_collection_view.rb', line 27

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

#view_classObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/nanoc/core/mutable_item_collection_view.rb', line 7

def view_class
  Nanoc::Core::MutableItemView
end