lib/skellington/template.rb in skellington-0.8.3 vs lib/skellington/template.rb in skellington-0.8.4

- old
+ new

@@ -29,25 +29,22 @@ f.write self end puts 'done' end - def to_s - path = "#{templates_dir}/#{@name}.eruby" - if @generator.files.dig(@name, 'common') - path = "#{common_templates}/#{@generator.files[@name]['common']}" + def path + [ + "#{templates_dir}/#{@name}", + "#{common_templates}/#{@generator.files.dig(@name, 'common')}", + "#{common_templates}/#{@name}" + ].each do |maybe_path| + return File.read(File.open(maybe_path)) if File.file? maybe_path end - begin - t = File.read(File.open(path)) + '' + end - # this can go away soon - if t =~ /^common: (.*)$/ - t = File.read(File.open("#{common_templates}/#{$1}")) - end - rescue Errno::ENOENT - t = File.read(File.open("#{common_templates}/#{@name}.eruby")) - end - Erubis::Eruby.new(t).evaluate(gen: @generator) + def to_s + Erubis::Eruby.new(path).evaluate(gen: @generator) end end end