0.02
No release in over 3 years
Low commit activity in last 3 years
Uses a .docx file with keyword tags within '||' as a template. This gem will then open the .docx and replace those tags with dynamically defined content.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.1
~> 2.14

Runtime

~> 4.3.1
~> 1.1
 Project Readme

Build Status Code Climate Dependency Status

Docx Templater

Use .docx as reusable templates

In your word document put placeholder names in double pipes || e.g. ||client_email1||

Example usage:

     buffer = DocxTemplater.new.replace_file_with_content('path/to/mydocument.docx',
        {
          :client_email1 => 'test@example.com',
          :client_phone1 => '555-555-5555',
        })
     # In Rails you can send a word document via send_data
     send_data buffer.string, :filename => 'REPC.docx'
     # Or save the output to a word file
     File.open("path/to/mydocument.docx", "wb") {|f| f.write(buffer.string) }

Newline Conversion

By default newlines in replacement values are converted to word document linebreak. If you need to ignore newlines you can pass a flag.

DocxTemplater.new(convert_newlines: false)
  .replace_file_with_content('path/to/file.docx',
    {quotes: "Be Excellent\nTo each other.\n~Bill and Ted's"})

Planned Changes

  • support for different tags (ie replace <<foo>> instead of ||foo||)