Sha256: fbe575687e02097e459443d7e560586e52b557169a3303654d7fd8f355b56fe7

Contents?: true

Size: 1016 Bytes

Versions: 6

Compression:

Stored size: 1016 Bytes

Contents

# frozen_string_literal: true

#
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

require 'base64'
require 'erb'
require 'forwardable'
require 'ostruct'
require 'proforma'

require_relative 'html_renderer/proforma_writer'

module Proforma
  # This main class to use as a Proforma renderer.
  class HtmlRenderer
    EXTENSION = '.html'

    DEFAULT_OPTIONS = {
      bold_weight: 'bold',
      font_family: 'sans-serif',
      header_font_size: 18,
      line_height_increase: 5,
      text_font_size: 13
    }.freeze

    attr_reader :options

    def initialize(options = {})
      @options = OpenStruct.new(DEFAULT_OPTIONS.merge(options))
    end

    def render(prototype)
      contents = ProformaWriter.render(prototype, options)

      Proforma::Document.new(
        contents: contents,
        extension: EXTENSION,
        title: prototype.title
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
proforma-html-renderer-1.0.4 lib/proforma/html_renderer.rb
proforma-html-renderer-1.0.3 lib/proforma/html_renderer.rb
proforma-html-renderer-1.0.2 lib/proforma/html_renderer.rb
proforma-html-renderer-1.0.1 lib/proforma/html_renderer.rb
proforma-html-renderer-1.0.0 lib/proforma/html_renderer.rb
proforma-html-renderer-1.0.0.pre.alpha lib/proforma/html_renderer.rb