Sha256: 6ef9e5df0eb6e8fca1dc2e8265b93496931b98c28c39c6a9a91590d3fb200f0f
Contents?: true
Size: 951 Bytes
Versions: 2
Compression:
Stored size: 951 Bytes
Contents
module Skellington class Template def initialize name, generator @name = name @generator = generator end def outpath @outpath ||= begin subs = @generator.files[@name]['outpath'].split '/' @outpath = "#{@generator.path}/#{@generator.send(subs[1].to_sym)}/#{@name.gsub(subs[0], @generator.send(subs[1].to_sym))}" rescue NoMethodError @outpath = "#{@generator.path}/#{@generator.wormname}/#{@name}" end end def templates_dir File.join File.dirname(__FILE__), '..', @generator.framework, 'templates' end def write print "Generating #{Skellington.unslash outpath}..." FileUtils.mkdir_p File.dirname outpath File.open outpath, 'w' do |f| f.write self end puts 'done' end def to_s t = File.read(File.open("#{templates_dir}/#{@name}.eruby")) Erubis::Eruby.new(t).evaluate(gen: @generator) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
skellington-0.8.1 | lib/skellington/template.rb |
skellington-0.8.0 | lib/skellington/template.rb |