Class: CodeTemplater

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CodeTemplater

Returns a new instance of CodeTemplater.



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

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

Instance Method Details

#content_for_suffix(prefix, suffix) ⇒ Object



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

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