Class Nanoc::ItemRep
In: lib/nanoc/base/result_data/item_rep.rb
Parent: Object

A single representation (rep) of an item ({Nanoc::Item}). An item can have multiple representations. A representation has its own output file. A single item can therefore have multiple output files, each run through a different set of filters with a different layout.

Methods

Included Modules

Deprecated Private

Classes and Modules

Module Nanoc::ItemRep::Deprecated
Module Nanoc::ItemRep::Private

External Aliases

binary -> binary?

Attributes

binary  [R]  @return [Boolean] true if this rep is currently binary; false otherwise
item  [R]  @return [Nanoc::Item] The item to which this rep belongs
name  [R]  @return [Symbol] The representation‘s unique name
snapshots  [RW]  @return [Array] A list of snapshots, represented as arrays where the
  first element is the snapshot name (a Symbol) and the last element is
  a Boolean indicating whether the snapshot is final or not

Public Class methods

Creates a new item representation for the given item.

@param [Nanoc::Item] item The item to which the new representation will

  belong.

@param [Symbol] name The unique name for the new item representation.

Public Instance methods

Returns the compiled content from a given snapshot.

@option params [String] :snapshot The name of the snapshot from which to

  fetch the compiled content. By default, the returned compiled content
  will be the content compiled right before the first layout call (if
  any).

@return [String] The compiled content at the given snapshot (or the

  default snapshot if no snapshot is specified)

Runs the item content through the given filter with the given arguments. This method will replace the content of the `:last` snapshot with the filtered content of the last snapshot.

This method is supposed to be called only in a compilation rule block (see {Nanoc::CompilerDSL#compile}).

@see Nanoc::ItemRepProxy#filter

@param [Symbol] filter_name The name of the filter to run the item

  representations' content through

@param [Hash] filter_args The filter arguments that should be passed to

  the filter's #run method

@return [void]

Checks whether content exists at a given snapshot.

@return [Boolean] True if content exists for the snapshot with the

  given name, false otherwise

@since 3.2.0

Returns false because this item is not yet a proxy, and therefore does need to be wrapped in a proxy during compilation.

@api private

@return [false]

@see Nanoc::ItemRepRecorderProxy#is_proxy? @see Nanoc::ItemRepProxy#is_proxy?

Lays out the item using the given layout. This method will replace the content of the `:last` snapshot with the laid out content of the last snapshot.

This method is supposed to be called only in a compilation rule block (see {Nanoc::CompilerDSL#compile}).

@see Nanoc::ItemRepProxy#layout

@param [Nanoc::Layout] layout The layout to use

@param [Symbol] filter_name The name of the filter to layout the item

  representations' content with

@param [Hash] filter_args The filter arguments that should be passed to

  the filter's #run method

@return [void]

Returns the item rep’s path, as used when being linked to. It starts with a slash and it is relative to the output directory. It does not include the path to the output directory. It will not include the filename if the filename is an index filename.

@option params [Symbol] :snapshot (:last) The snapshot for which the

  path should be returned

@return [String] The item rep’s path

Returns the item rep’s raw path. It includes the path to the output directory and the full filename.

@option params [Symbol] :snapshot (:last) The snapshot for which the

  path should be returned

@return [String] The item rep’s path

Returns an object that can be used for uniquely identifying objects.

@api private

@return [Object] An unique reference to this object

Creates a snapshot of the current compiled item content.

@param [Symbol] snapshot_name The name of the snapshot to create

@option params [Boolean] :final (true) True if this is the final time

  the snapshot will be updated; false if it is a non-final moving
  snapshot (such as `:pre`, `:post` or `:last`)

@return [void]

Returns a recording proxy that is used for determining whether the compilation has changed, and thus whether the item rep needs to be recompiled.

@api private

@return [Nanoc::ItemRepRecorderProxy] The recording proxy

[Validate]