Parent

Class/Module Index [+]

Quicksearch

Nanoc::ItemRepProxy

Represents an item representation, but provides an interface that is easier to use when writing compilation and routing rules. It is also responsible for fetching the necessary information from the compiler, such as assigns.

The API provided by item representation proxies allows layout identifiers to be given as literals instead of as references to {Nanoc::Layout}.

Public Class Methods

new(item_rep, compiler) click to toggle source

@param [Nanoc::ItemRep] item_rep The item representation that this

proxy should behave like

@param [Nanoc::Compiler] compiler The compiler that will provide the

necessary compilation-related functionality.
# File lib/nanoc/base/compilation/item_rep_proxy.rb, line 23
def initialize(item_rep, compiler)
  @item_rep = item_rep
  @compiler = compiler
end

Public Instance Methods

filter(name, args={}) click to toggle source

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::ItemRep#filter

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

representations' content through

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

filter's #run method

@return [void]

# File lib/nanoc/base/compilation/item_rep_proxy.rb, line 44
def filter(name, args={})
  set_assigns
  @item_rep.filter(name, args)
end
is_proxy?() click to toggle source

Returns true because this item is already a proxy, and therefore doesn’t need to be wrapped anymore.

@api private

@return [true]

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

# File lib/nanoc/base/compilation/item_rep_proxy.rb, line 80
def is_proxy?
  true
end
layout(layout_identifier, extra_filter_args={}) click to toggle source

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::ItemRep#layout

@param [String] layout_identifier The identifier of the layout to use

@return [void]

# File lib/nanoc/base/compilation/item_rep_proxy.rb, line 61
def layout(layout_identifier, extra_filter_args={})
  set_assigns

  layout = layout_with_identifier(layout_identifier)
  filter_name, filter_args = @compiler.rules_collection.filter_for_layout(layout)
  filter_args = filter_args.merge(extra_filter_args)

  @item_rep.layout(layout, filter_name, filter_args)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.