GREATLY SIMPLIFIED the gentext.template template.