
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Caracal is a ruby library for dynamically creating professional-quality Microsoft Word documents.
Caracal-Rails is a drop in solution for registering the Microsoft Word mime type and for establishing a template handler in Rails for the :docx format. All caracal documents are rendered with an explicit block passing a reference to the Caracal::Document object named docx
.
Please see the caracal-example repository for a working demonstration of the library's capabilities.
Add this line to your application's Gemfile:
gem 'caracal-rails'
Then execute:
$ bundle install
Design your controller normally and respond to the docx
format:
class ReportsController < ApplicationController
def show
# collect your models/view models here
respond_to do |format|
format.docx { headers["Content-Disposition"] = "attachment; filename=\"caracal.docx\"" }
end
end
end
Then add a view file with the Caracal extension:
apps/views/reports/show.docx.caracal
Specify the format docx
in your route:
resources :reports, only: [:show], format: 'docx'
Inside your view, simply issue Caracal commands on the document object:
docx.font 'Droid Serif'
docx.style 'special' do
font 'Droid Serif'
italic true
size 16
end
docx.h1 'Quarterly Report'
docx.hr
@report.clients.each do |client|
docx.h2 client.name
docx.p 'Lorem ipsum dolor...'
docx.p do
text 'This is a sentence with a '
link 'link', 'http://www.google.com/', style: 'special'
text ' in the middle.'
end
docx.img image_url('https://www.example.com/logo.png'), width: 300, height: 200, align: 'right'
docx.br
docx.table client.tablular_data, border_size: 4 do
cell_style rows[0], background_color: '3366cc', color: 'ffffff', bold: true
end
docx.page
docx.p 'This is an bulleted list.'
docx.ul do
li do
strong 'Item 1'
text 'More text'
end
li 'Item 2'
end
end
See the Caracal library for more details.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Because my son likes caracals. :)
A tip of the hat to the wonderful PDF generation libraries Prawn and Prawnto.
Copyright (c) 2014 Trade Informatics, Inc
FAQs
Unknown package
We found that caracal-rails demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
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.