Sha256: 53698239a09abb6d6fcdc301263ffd7ae061d6ad47528699abc6735391a02b3d
Contents?: true
Size: 765 Bytes
Versions: 2
Compression:
Stored size: 765 Bytes
Contents
# frozen_string_literal: true module Ezframe class Template class << self def fill(filename, opts = {}) dir = File.dirname(filename) unless File.exist?(filename) raise "fill_template: file does not exist: #{filename}" end instr = File.open(filename, &:read) return fill_in_text(instr, opts) end def fill_in_text(text, opts = {}) outstr = text.gsub(/\#\{([^\}]+)\}/) do keyword = $1 if opts[keyword.to_sym] opts[keyword.to_sym] elsif ENV[keyword] ENV[keyword] else mylog "[WARN] no value for keyword: #{keyword}" nil end end return outstr end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ezframe-0.1.1 | lib/ezframe/template.rb |
ezframe-0.1.0 | lib/ezframe/template.rb |