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.
-
- (true) is_proxy?
private
Returns true because this item is already a proxy, and therefore doesn’t need to be wrapped anymore.
-
- (void) layout(layout_identifier, extra_filter_args = {})
Lays out the item using the given layout.
Constructor Details
- (ItemRepProxy) initialize(item_rep, compiler)
Returns a new instance of ItemRepProxy
24 25 26 27 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 24 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).
45 46 47 48 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 45 def filter(name, args = {}) set_assigns @item_rep.filter(name, args) end |
- (true) 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.
81 82 83 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 81 def is_proxy? true 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).
62 63 64 65 66 67 68 69 70 |
# File 'lib/nanoc/base/compilation/item_rep_proxy.rb', line 62 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 |