Class: Producer::Core::Template
- Inherits:
-
Object
- Object
- Producer::Core::Template
- Defined in:
- lib/producer/core/template.rb
Constant Summary collapse
- SEARCH_PATH =
'templates'.freeze
Instance Method Summary collapse
-
#initialize(path, search_path: SEARCH_PATH) ⇒ Template
constructor
A new instance of Template.
- #render(variables = {}) ⇒ Object
Constructor Details
#initialize(path, search_path: SEARCH_PATH) ⇒ Template
Returns a new instance of Template.
6 7 8 9 |
# File 'lib/producer/core/template.rb', line 6 def initialize(path, search_path: SEARCH_PATH) @path = Pathname.new(path) @search_path = Pathname.new(search_path) end |
Instance Method Details
#render(variables = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/producer/core/template.rb', line 11 def render(variables = {}) case (file_path = resolve_path).extname when '.yaml' then render_yaml file_path when '.erb' then render_erb file_path, variables end end |