lib/architecture-js/generator.rb in architecture-js-0.3.0 vs lib/architecture-js/generator.rb in architecture-js-0.3.1
- old
+ new
@@ -33,21 +33,26 @@
def read_template(file)
ERB.new(File.read(file), nil, '<>')
end
- def generate(template, filename, options, arguments)
+ def generate(config)
+ template = config[:template]
raise "There is no template named #{template} in the #{@blueprint[:name]} project" if @templates[template].nil?
- filename = "#{filename}#{@templates[template][:ext]}"
- generate_file(filename, render_template(template, options))
+
+ options = config[:options]
+ arguments = config[:arguments]
+ filename = "#{config[:filename]}#{@templates[template][:ext]}"
+
+ generate_file(filename, render_template(template, filename, arguments, options))
end
def generate_file(filename, template, path = nil)
path ||= File.expand_path(Dir.getwd)
File.open("#{path}/#{filename}", "w+") { |f| f.write template }
end
- def render_template(template, options = nil)
+ def render_template(template, filename, arguments, options)
blueprint = @blueprint
project = @project
@templates[template][:erb].result(binding)
end
end
\ No newline at end of file