Sha256: c69e9f3b6b3acda28319dabfb3943a1d3c43a6a06d0fbbd2dfcfdd0f7d64ec35

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

require 'erb'
require 'review/extentions'
module ReVIEW
  class Template
    include ERB::Util

    TEMPLATE_DIR = File.join(File.dirname(__FILE__), '../../templates')

    def self.load(filename, mode = 1)
      self.new(filename, mode)
    end

    def self.generate(path:, binding:, mode: 1, template_dir: ReVIEW::Template::TEMPLATE_DIR)
      template_file = File.expand_path(path, template_dir)
      self.new(template_file, mode).result(binding)
    end

    def initialize(filename = nil, mode = nil)
      return unless filename

      content = File.read(filename)
      @erb = ERB.new(content, nil, mode)
    end

    def result(bind_data = nil)
      @erb.result(bind_data)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
review-5.1.1 lib/review/template.rb
review-5.1.0 lib/review/template.rb