Class: Nanoc::Core::CompilationItemView

Inherits:
BasicItemView show all
Defined in:
lib/nanoc/core/compilation_item_view.rb

Direct Known Subclasses

PostCompileItemView

Instance Method Summary collapse

Methods inherited from BasicItemView

#binary?, #children, #parent, #raw_filename

Methods included from DocumentViewMixin

#==, #[], #_unwrap, #attributes, #eql?, #fetch, #hash, #identifier, #initialize, #inspect, #key?, #raw_content, #reference

Methods inherited from View

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

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Instance Method Details

#compiled_content(rep: :default, snapshot: nil) ⇒ String

Returns the compiled content.

Parameters:

  • rep (String) (defaults to: :default)

    The name of the representation from which the compiled content should be fetched. By default, the compiled content will be fetched from the default representation.

  • snapshot (String) (defaults to: nil)

    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).

Returns:

  • (String)

    The content of the given rep at the given snapshot.



18
19
20
# File 'lib/nanoc/core/compilation_item_view.rb', line 18

def compiled_content(rep: :default, snapshot: nil)
  reps.fetch(rep).compiled_content(snapshot: snapshot)
end

#path(rep: :default, snapshot: :last) ⇒ String

Returns the item 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.

Parameters:

  • rep (String) (defaults to: :default)

    The name of the representation from which the path should be fetched. By default, the path will be fetched from the default representation.

  • snapshot (Symbol) (defaults to: :last)

    The snapshot for which the path should be returned.

Returns:

  • (String)

    The item’s path.



35
36
37
# File 'lib/nanoc/core/compilation_item_view.rb', line 35

def path(rep: :default, snapshot: :last)
  reps.fetch(rep).path(snapshot: snapshot)
end

#repsNanoc::Core::BasicItemRepCollectionView

Returns the representations of this item.



42
43
44
# File 'lib/nanoc/core/compilation_item_view.rb', line 42

def reps
  Nanoc::Core::CompilationItemRepCollectionView.new(@context.reps[_unwrap], @context)
end