Generate template from script