Class: RamlRubyClient::Generator::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/raml_ruby_client/generator/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_name) ⇒ Template

Returns a new instance of Template.



36
37
38
39
# File 'lib/raml_ruby_client/generator/template.rb', line 36

def initialize(template_name)
  file = File.join(TEMPLATE_DIR, template_name)
  @erb = ERB.new(File.read(file), nil, '-')
end

Class Method Details

.load(template_name) ⇒ Object



32
33
34
# File 'lib/raml_ruby_client/generator/template.rb', line 32

def self.load(template_name)
  Template.new(sprintf('%s.tmpl', template_name))
end

Instance Method Details

#render(context) ⇒ Object



41
42
43
44
# File 'lib/raml_ruby_client/generator/template.rb', line 41

def render(context)
  ctx = Context.new(context)
  @erb.result(ctx.to_binding)
end