Module: Nanoc::WithRepsViewMixin

Included in:
ItemWithRepsView
Defined in:
lib/nanoc/base/views/mixins/with_reps_view_mixin.rb

Instance Method Summary collapse

Instance Method Details

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

Returns the compiled content.

Parameters:

  • rep (String)

    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)

    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.



17
18
19
# File 'lib/nanoc/base/views/mixins/with_reps_view_mixin.rb', line 17

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)

    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)

    The snapshot for which the path should be returned.

Returns:

  • (String)

    The item’s path.



34
35
36
# File 'lib/nanoc/base/views/mixins/with_reps_view_mixin.rb', line 34

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

#repsNanoc::ItemRepCollectionView

Returns the representations of this item.



41
42
43
# File 'lib/nanoc/base/views/mixins/with_reps_view_mixin.rb', line 41

def reps
  Nanoc::ItemRepCollectionView.new(@context.reps[unwrap], @context)
end