Class: Yutani::Template

Inherits:
OpenStruct
  • Object
show all
Includes:
Hiera
Defined in:
lib/yutani/template.rb

Overview

an openstruct is useful because it lets us take a hash and turn its k/v’s into local variables inside the tmpl

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hiera

#hiera, init_hiera, lookup, pop, push, scope

Class Method Details

.templates_pathObject



12
13
14
# File 'lib/yutani/template.rb', line 12

def templates_path
  Yutani.config['templates_dir']
end

Instance Method Details

#render(path) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/yutani/template.rb', line 17

def render(path)
  full_path = File.join(Template.templates_path, path)

  unless File.exists?(full_path)
    raise TemplateNotFoundError, full_path
  end

  ERB.new(File.read(full_path)).result binding
end