module Concourse::Util
def erbify_file filename, working_directory: nil
def erbify_file filename, working_directory: nil raise "ERROR: erbify_file: could not find file `#{filename}`" unless File.exist?(filename) template = File.read(filename) if working_directory.nil? working_directory = "." # so chdir is a no-op below else fqwd = File.expand_path(working_directory) $LOAD_PATH << fqwd unless $LOAD_PATH.include?(fqwd) # so "require" can load relative paths end Dir.chdir(working_directory) { ERB.new(template, nil, "%-").result(binding) } end