Class: Rdm::Support::Template
- Inherits:
-
Object
- Object
- Rdm::Support::Template
- Defined in:
- lib/rdm/support/template.rb
Instance Attribute Summary collapse
-
#tmpl_path ⇒ Object
Returns the value of attribute tmpl_path.
Instance Method Summary collapse
- #construct_path(some_path = nil) ⇒ Object
- #content(file, locals = {}) ⇒ Object
- #default_templates_path ⇒ Object
-
#initialize(tmpl_path = nil) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(tmpl_path = nil) ⇒ Template
Returns a new instance of Template.
5 6 7 |
# File 'lib/rdm/support/template.rb', line 5 def initialize(tmpl_path = nil) @tmpl_path = construct_path(tmpl_path) end |
Instance Attribute Details
#tmpl_path ⇒ Object
Returns the value of attribute tmpl_path.
4 5 6 |
# File 'lib/rdm/support/template.rb', line 4 def tmpl_path @tmpl_path end |
Instance Method Details
#construct_path(some_path = nil) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rdm/support/template.rb', line 15 def construct_path(some_path = nil) Pathname.new( File.( (some_path || default_templates_path) ) ) end |
#content(file, locals = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/rdm/support/template.rb', line 9 def content(file, locals = {}) path = tmpl_path.join(file) content = File.read(path) Rdm::Support::Render.render(content, locals) end |
#default_templates_path ⇒ Object
23 24 25 26 27 |
# File 'lib/rdm/support/template.rb', line 23 def default_templates_path File.( File.join(File.dirname(__FILE__), '..', 'templates') ) end |