Sha256: 6ac8c3f2daf596d99c3c1a817043b5e9acdd70fa4801025bac86dad876fa3638

Contents?: true

Size: 622 Bytes

Versions: 22

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

module Docs
  class Template
    attr_reader :data,
                :destination_path,
                :template_path

    def initialize(args = {})
      @data = args.fetch(:data)
      @destination_path = args.fetch(:destination_path)
      @template_path = args.fetch(:template_path)
    end

    def write
      template = ERB.new(File.read(template_path), trim_mode: '-')
      yellow "Generating template: #{template_path}"
      File.open(destination_path, 'w') { |f| f.write template.result_with_hash(data) }
      green "Wrote to destination: #{destination_path}"
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ledger_sync-1.4.1 documentation/generators/template.rb
ledger_sync-1.4.0 documentation/generators/template.rb