Class: Nanoc::ItemRepView

Inherits:
View
  • Object
show all
Defined in:
lib/nanoc/base/views/item_rep_view.rb

Instance Method Summary (collapse)

Methods inherited from View

#_context, #frozen?

Instance Method Details

- (Object) ==(other) Also known as: eql?

See Also:

  • Object#==


15
16
17
# File 'lib/nanoc/base/views/item_rep_view.rb', line 15

def ==(other)
  other.respond_to?(:item) && other.respond_to?(:name) && item == other.item && name == other.name
end

- (String) compiled_content(snapshot: nil)

Returns the compiled content.

Parameters:

  • 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 at the given snapshot.



38
39
40
41
42
43
# File 'lib/nanoc/base/views/item_rep_view.rb', line 38

def compiled_content(snapshot: nil)
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
  Nanoc::Int::NotificationCenter.post(:visit_ended,   unwrap.item)

  @item_rep.compiled_content(snapshot: snapshot)
end

- (Object) hash

See Also:

  • Object#hash


21
22
23
# File 'lib/nanoc/base/views/item_rep_view.rb', line 21

def hash
  self.class.hash ^ item.identifier.hash ^ name.hash
end

- (Nanoc::ItemWithRepsView) item

Returns the item that this item rep belongs to.



64
65
66
# File 'lib/nanoc/base/views/item_rep_view.rb', line 64

def item
  Nanoc::ItemWithRepsView.new(@item_rep.item, @context)
end

- (Symbol) name

Returns:

  • (Symbol)


26
27
28
# File 'lib/nanoc/base/views/item_rep_view.rb', line 26

def name
  @item_rep.name
end

- (String) path(snapshot: :last)

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.

Parameters:

  • snapshot (Symbol)

    The snapshot for which the path should be returned.

Returns:

  • (String)

    The item rep’s path.



54
55
56
57
58
59
# File 'lib/nanoc/base/views/item_rep_view.rb', line 54

def path(snapshot: :last)
  Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
  Nanoc::Int::NotificationCenter.post(:visit_ended,   unwrap.item)

  @item_rep.path(snapshot: snapshot)
end