Class: Stasis::Helpers
Instance Method Summary (collapse)
-
- (Object) before_render
This event triggers before each file renders through Stasis.
-
- (Object) helpers(&block)
This method is bound to all controllers.
-
- (Helpers) initialize(stasis)
constructor
A new instance of Helpers.
-
- (Object) reset
This event resets all instance variables.
Methods inherited from Plugin
#_match_key?, _priority, #_within?, inherited, plugins, priority
Constructor Details
- (Helpers) initialize(stasis)
A new instance of Helpers
8 9 10 11 |
# File 'lib/stasis/plugins/helpers.rb', line 8 def initialize(stasis) @stasis = stasis reset end |
Instance Method Details
- (Object) before_render
This event triggers before each file renders through Stasis. For each helper `block`, evaluate the `block` in the scope of the `action` class.
15 16 17 18 19 20 21 |
# File 'lib/stasis/plugins/helpers.rb', line 15 def before_render @blocks.each do |(path, block)| if _within?(path) @stasis.action.class.class_eval(&block) end end end |
- (Object) helpers(&block)
This method is bound to all controllers. Stores a block in the `@blocks` `Array`.
24 25 26 27 28 |
# File 'lib/stasis/plugins/helpers.rb', line 24 def helpers(&block) if block @blocks << [ @stasis.path, block ] end end |
- (Object) reset
This event resets all instance variables.
31 32 33 |
# File 'lib/stasis/plugins/helpers.rb', line 31 def reset @blocks = [] end |