Class: Nanoc3::ItemRepProxy
- Inherits:
-
Object
- Object
- Nanoc3::ItemRepProxy
- Extended by:
- Forwardable
- Defined in:
- lib/nanoc3/base/compilation/item_rep_proxy.rb
Overview
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 Layout.
Instance Method Summary collapse
-
#filter(name, args = {}) ⇒ void
Runs the item content through the given filter with the given arguments.
-
#initialize(item_rep, compiler) ⇒ ItemRepProxy
constructor
A new instance of ItemRepProxy.
-
#is_proxy? ⇒ true
private
Returns true because this item is already a proxy, and therefore doesn’t need to be wrapped anymore.
-
#layout(layout_identifier) ⇒ void
Lays out the item using the given layout.
Constructor Details
#initialize(item_rep, compiler) ⇒ ItemRepProxy
Returns a new instance of ItemRepProxy.
24 25 26 27 |
# File 'lib/nanoc3/base/compilation/item_rep_proxy.rb', line 24 def initialize(item_rep, compiler) @item_rep = item_rep @compiler = compiler end |
Instance Method Details
#filter(name, args = {}) ⇒ void
This method returns an undefined value.
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 CompilerDSL#compile).
45 46 47 48 |
# File 'lib/nanoc3/base/compilation/item_rep_proxy.rb', line 45 def filter(name, args={}) set_assigns @item_rep.filter(name, args) end |
#is_proxy? ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns true because this item is already a proxy, and therefore doesn’t need to be wrapped anymore.
80 81 82 |
# File 'lib/nanoc3/base/compilation/item_rep_proxy.rb', line 80 def is_proxy? true end |
#layout(layout_identifier) ⇒ void
This method returns an undefined value.
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 CompilerDSL#compile).
62 63 64 65 66 67 68 69 |
# File 'lib/nanoc3/base/compilation/item_rep_proxy.rb', line 62 def layout(layout_identifier) set_assigns layout = layout_with_identifier(layout_identifier) filter_name, filter_args = @compiler.rules_collection.filter_for_layout(layout) @item_rep.layout(layout, filter_name, filter_args) end |