Class: CodeTemplater

Inherits:
Object
  • Object
show all
Defined in:
lib/ccios/code_templater.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, templates_path) ⇒ CodeTemplater

Returns a new instance of CodeTemplater.



5
6
7
8
# File 'lib/ccios/code_templater.rb', line 5

def initialize(options = {}, templates_path)
  @options = options
  @templates_path = templates_path
end

Instance Method Details

#content_for_suffix(prefix, suffix) ⇒ Object



10
11
12
13
14
15
# File 'lib/ccios/code_templater.rb', line 10

def content_for_suffix(prefix, suffix)
  template_name = suffix.underscore
  options = @options.merge({name: prefix, lowercased_name: prefix.camelize(:lower)})
  template_file = File.join(@templates_path, "#{template_name}.mustache")
  Mustache.render(File.read(template_file), options)
end