Class: Twiddler::Rendering
- Inherits:
-
Object
- Object
- Twiddler::Rendering
- Defined in:
- lib/twiddler/rendering.rb
Instance Method Summary collapse
- #embed(name) ⇒ Object
-
#initialize(config) ⇒ Rendering
constructor
A new instance of Rendering.
- #template_path(name) ⇒ Object
Constructor Details
#initialize(config) ⇒ Rendering
Returns a new instance of Rendering.
5 6 7 |
# File 'lib/twiddler/rendering.rb', line 5 def initialize(config) @config = config end |
Instance Method Details
#embed(name) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/twiddler/rendering.rb', line 9 def (name) path = template_path(name) template = File::read(path) erb = ERB.new(template, nil, "%>") erb.filename = path mod = erb.def_module("render") @config.extend(mod) end |
#template_path(name) ⇒ Object
18 19 20 21 |
# File 'lib/twiddler/rendering.rb', line 18 def template_path(name) path = File::("../../templates/#{name}.erb", File::dirname(__FILE__)) end |