
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
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.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.