lib/nanoc/base/views/item_rep_view.rb in nanoc-4.0.2 vs lib/nanoc/base/views/item_rep_view.rb in nanoc-4.1.0a1
- old
+ new
@@ -1,9 +1,10 @@
module Nanoc
- class ItemRepView
+ class ItemRepView < ::Nanoc::View
# @api private
- def initialize(item_rep)
+ def initialize(item_rep, context)
+ super(context)
@item_rep = item_rep
end
# @api private
def unwrap
@@ -26,51 +27,51 @@
@item_rep.name
end
# Returns the compiled content.
#
- # @option params [String] :snapshot The name of the snapshot from which to
+ # @param [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 content at the given snapshot.
- def compiled_content(params = {})
+ 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(params)
+ @item_rep.compiled_content(snapshot: snapshot)
end
# 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.
+ # @param [Symbol] snapshot The snapshot for which the path should be
+ # returned.
#
# @return [String] The item rep’s path.
- def path(params = {})
+ def path(snapshot: :last)
Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap.item)
- @item_rep.path(params)
+ @item_rep.path(snapshot: snapshot)
end
# Returns the item that this item rep belongs to.
#
# @return [Nanoc::ItemView]
def item
- Nanoc::ItemView.new(@item_rep.item)
+ Nanoc::ItemView.new(@item_rep.item, @context)
end
# @api private
- def raw_path(params = {})
+ def raw_path(snapshot: :last)
Nanoc::Int::NotificationCenter.post(:visit_started, unwrap.item)
Nanoc::Int::NotificationCenter.post(:visit_ended, unwrap.item)
- @item_rep.raw_path(params)
+ @item_rep.raw_path(snapshot: snapshot)
end
# @api private
def binary?
@item_rep.binary?