Sha256: 68e565fe13d39f692ecd601d5456b808e9d943fbba404fb89c9ae152dd0e9455
Contents?: true
Size: 935 Bytes
Versions: 1
Compression:
Stored size: 935 Bytes
Contents
# encoding: UTF-8 module Gjp # operates on files in template/ class TemplateManager include Logging attr_reader :template_path def initialize @template_path = File.join(File.dirname(__FILE__), "..", "template") end # copies a template file in a directory def copy(template_name, destination_dir) FileUtils.cp_r(File.join(template_path, template_name), destination_dir) end # generates content from an ERB template and an object binding # if destination_path is given, write it to that file, otherwise just # return it def generate(template_name, object_binding, destination_path = nil) erb = ERB.new File.read(File.join(template_path, template_name)), nil, "<>" new_content = erb.result(object_binding) unless destination_path.nil? File.open(destination_path, "w") { |io| io.write new_content } end new_content end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gjp-0.39.0 | lib/gjp/template_manager.rb |