
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Gem used to create docx files based on a template. Our idea is quite similar to an erb file (in fact, we use an erb file behind :P) The only difference is:
For example, in our template file example.docx we could have:
{{ items.each do |item| }}
Insert here some text: {{% item.property %}}
{{ end }}
In order to render a table on docx template, we wrote:
{{t config t}}
where "config" is a hash that may contain five properties:
At this moment, table width, font family and font size are the only table customizations available (after version 0.5.0)
Add this line to your application's Gemfile:
gem 'docx-builder'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install docx-builder
builder = Docx::Builder::Template.new('/path/to/input.docx')
new_xml = builder.render(variables_hash)
builder.save('/path/to/output.docx', new_xml)
# or memory_stream = builder.save_as_buffer(new_xml)
An example of table configuration should be:
{
columns: [
{
name: :name,
description: 'Name',
width: 50
},
{
name: :email,
description: 'Mail address',
width: 50
}
],
rows: [
{
name: 'João',
email: 'joao@example.com'
},
{
name: 'José',
email: 'jose@example.com'
},
{
name: 'Felipe',
email: 'felipe@example.com'
}
],
table_width: 400,
font_family: 'Cambria',
font_size: 14
}
You can also use a helper to generate the hash presented above. For this example, you may specify the description for each column in an internationalization file (i18n), otherwise its name (symbol) will be used instead.
people = [
{ name: 'João', email: 'joao@example.com' },
{ name: 'José', email: 'jose@example.com' },
{ name: 'Felipe', email: 'felipe@example.com' }
]
Docx::Utils.build_table_config_from_array(people, table_width: 400, font_family: 'Cambria', font_size: 14)
docx_builder:
tables:
columns:
name: Name
email: Mail Address
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/docx-builder. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Docx::Builder project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that docx-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.