Sha256: 8f0007c4aa899d99c6a4b670b7a6eebabceb221b4529efecfad17f442c427a3c
Contents?: true
Size: 863 Bytes
Versions: 9
Compression:
Stored size: 863 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 = if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.6') ERB.new(content, trim_mode: mode) else ERB.new(content, nil, mode) end end def result(bind_data = nil) @erb.result(bind_data) end end end
Version data entries
9 entries across 9 versions & 1 rubygems