module DocxTemplater

Constants

VERSION

Public Instance Methods

log(str) click to toggle source
# File lib/docx_templater.rb, line 8
def log(str)
  # braindead logging
  puts str if ENV['DEBUG']
end
open_output_file(output_file) click to toggle source

Open word file in mac os(with word installed)

# File lib/docx_templater.rb, line 36
def open_output_file(output_file)
  puts "\n************************************"
  puts '   >>> Only will work on mac <<<'
  puts 'NOW attempting to open created file in Word.'
  cmd = "open #{output_file}"
  puts "  will run '#{cmd}'"
  puts '************************************'

  system cmd
end
template_docx(options = {}) click to toggle source

template docx file

@param {Hash} options -

@example

options = {
  input_file: 'xxx',
  output_file: 'xxx',
  data: { key: value }
}
# File lib/docx_templater.rb, line 23
def template_docx(options = {})
  puts "options: #{options}"

  DocxTemplater::DocxCreator.new(options[:input_file], options[:data]).generate_docx_file(options[:output_file])

  archive = Zip::File.open(options[:output_file])
  archive.close

  DocxTemplater.open_output_file options[:output_file]
end