Class: Nanoc3::RuleContext
- Inherits:
-
Context
- Object
- Context
- Nanoc3::RuleContext
- Defined in:
- lib/nanoc3/base/rule_context.rb
Overview
Provides a context in which compilation and routing rules can be executed. It provides access to the item representation that is being compiled or routed.
The following variables will be available in this rules context:
Instance Method Summary (collapse)
-
- (void) filter(filter_name, filter_args = {})
Filters the current representation (calls ItemRep#filter with the given arguments on the rep).
-
- (RuleContext) initialize(rep)
constructor
Creates a new rule context for the given item representation.
-
- (void) layout(layout_identifier)
Layouts the current representation (calls ItemRep#layout with the given arguments on the rep).
-
- (void) snapshot(snapshot_name)
Creates a snapshot of the current compiled item content.
Methods inherited from Context
Constructor Details
- (RuleContext) initialize(rep)
Creates a new rule context for the given item representation.
a new rule context.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nanoc3/base/rule_context.rb', line 21 def initialize(rep) item = rep.item site = item.site config = site.config items = site.items layouts = site.layouts super({ :rep => rep, :item => item, :site => site, :config => config, :items => items, :layouts => layouts }) end |
Instance Method Details
- (void) filter(filter_name, filter_args = {})
This method returns an undefined value.
Filters the current representation (calls ItemRep#filter with the given arguments on the rep).
representations' content through
the filter's #run method
50 51 52 |
# File 'lib/nanoc3/base/rule_context.rb', line 50 def filter(filter_name, filter_args={}) rep.filter(filter_name, filter_args) end |
- (void) layout(layout_identifier)
This method returns an undefined value.
Layouts the current representation (calls ItemRep#layout with the given arguments on the rep).
should be laid out with
63 64 65 |
# File 'lib/nanoc3/base/rule_context.rb', line 63 def layout(layout_identifier) rep.layout(layout_identifier) end |
- (void) snapshot(snapshot_name)
This method returns an undefined value.
Creates a snapshot of the current compiled item content. Calls ItemRep#snapshot with the given arguments on the rep.
75 76 77 |
# File 'lib/nanoc3/base/rule_context.rb', line 75 def snapshot(snapshot_name) rep.snapshot(snapshot_name) end |