Ported Template.rb