Proforma HTML Renderer
Proforma ships with a basic plain-text renderer. Luckily we can plug in different rendering engines to provide additional business value. This library gives Proforma the ability to render HTML instead of simple plain-text.
Installation
To install through Rubygems:
gem install install proforma-html-renderer
You can also add this to your Gemfile:
bundle add proforma-html-renderer
Note: If you are using bundler for auto-requiring then you need to specify as:
gem 'proforma-html-renderer', require: 'proforma/html_renderer'
Examples
Connecting to Proforma Rendering Pipeline
To use this plugin within Proforma:
- Install Proforma
- Install this library
- Require both libraries
- Pass in an instance of Proforma::HtmlRenderer into the Proforma#render method
require 'proforma'
require 'proforma/html_renderer'
data = [
{ id: 1, name: 'Chicago Bulls' },
{ id: 2, name: 'Indiana Pacers' },
{ id: 3, name: 'Boston Celtics' }
]
template = {
title: 'nba_team_list',
children: [
{ type: 'Header', value: 'NBA Teams' },
{ type: 'Separator' },
{
type: 'DataTable',
columns: [
{ header: 'Team ID #', body: '$id' },
{ header: 'Team Name', body: '$name' },
]
}
]
}
documents = Proforma.render(data, template, renderer: Proforma::HtmlRenderer.new)
The documents
attribute will now be an array with one object:
expected_documents = [
{
contents: "...", # HTML Data
extension: '.html',
title: 'nba_team_list'
}
]
The contents
attribute will contain the HTML.
Customization
All options are passed into Proforma::HtmlRenderer#initialize as a hash:
Name | Default |
---|---|
bold_weight | bold |
font_family | sans-serif |
header_font_size | 18 |
line_height_increase | 5 |
text_font_size | 13 |
These options will be used during the rendering process.
Contributing
Development Environment Configuration
Basic steps to take to get this repository compiling:
- Install Ruby (check proforma-html-renderer.gemspec for versions supported)
- Install bundler (gem install bundler)
- Clone the repository (git clone [email protected]:bluemarblepayroll/proforma-html-renderer.git)
- Navigate to the root folder (cd proforma)
- Install dependencies (bundle)
Running Tests
To execute the test suite run:
bundle exec rspec spec --format documentation
Alternatively, you can have Guard watch for changes:
bundle exec guard
Also, do not forget to run Rubocop:
bundle exec rubocop
Publishing
Note: ensure you have proper authorization before trying to publish new versions.
After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
- Merge Pull Request into master
- Update
lib/proforma/html_renderer/version.rb
using semantic versioning - Install dependencies:
bundle
- Update
CHANGELOG.md
with release notes - Commit & push master to remote and ensure CI builds master successfully
- Run
bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the.gem
file to rubygems.org.
License
This project is MIT Licensed.