Class: Nanoc::ItemRepProxy
- Inherits:
-
Object
- Object
- Nanoc::ItemRepProxy
- Extended by:
- Forwardable
- Defined in:
- lib/nanoc/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)
-
- (void) filter(name, args = {})
Runs the item content through the given filter with the given arguments.
-
- (ItemRepProxy) initialize(item_rep, compiler)
constructor
A new instance of ItemRepProxy.
-
- (void) layout(layout_identifier, extra_filter_args = {})
Lays out the item using the given layout.
-
- (true) proxy?
(also: #is_proxy?)
private
Returns true because this item is already a proxy, and therefore doesn’t need to be wrapped anymore.
Constructor Details
- (ItemRepProxy) initialize(item_rep, compiler)
Returns a new instance of ItemRepProxy
22 23 24 25 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 22 def initialize(item_rep, compiler) @item_rep = item_rep @compiler = compiler end |
Instance Method Details
- (void) filter(name, args = {})
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).
43 44 45 46 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 43 def filter(name, args = {}) set_assigns @item_rep.filter(name, args) end |
- (void) layout(layout_identifier, extra_filter_args = {})
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).
60 61 62 63 64 65 66 67 68 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 60 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 |
- (true) proxy? Also known as: is_proxy?
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.
79 80 81 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 79 def proxy? true end |