Class: Producer::Core::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/producer/core/template.rb

Constant Summary collapse

SEARCH_PATH =
'templates'.freeze

Instance Method Summary collapse

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