Module: Waves::Renderers::Mixin
Overview
The renderers mixin provides a number of methods to simplify writing new renderers. Just include this in your Renderer class and write your render method.
Instance Method Summary collapse
- #filename(path) ⇒ Object
- #helper(path) ⇒ Object
-
#included(app) ⇒ Object
Adds the following methods to the mod class:.
- #template(path) ⇒ Object
Instance Method Details
#filename(path) ⇒ Object
20 21 22 |
# File 'lib/renderers/mixin.rb', line 20 def filename(path) "#{path}.#{self::Extension}" end |
#helper(path) ⇒ Object
28 29 30 |
# File 'lib/renderers/mixin.rb', line 28 def helper( path ) Waves.main[ :helpers ][ File.basename( File.dirname( path ) ).camel_case ] end |
#included(app) ⇒ Object
Adds the following methods to the mod class:
-
filename: generate a filename for the template based on a logical path.
-
template: read the template from the file corresponding to the given logical path.
-
helper: return a helper module that corresponds to the given logical path.
16 17 18 |
# File 'lib/renderers/mixin.rb', line 16 def included( app ) Waves::Views.renderers << self end |