Hmmm - looking now at the post, the HTML lines are really long, but looking back at the code, it seems like I was lazy :
The code slurps in the whole template, but it dosen't replace variables except in the first line of each template
(in &ReplaceVars(), the regular expression should have /ms at the end). I'll test the code and then modify it, but until then, it'll stay in the ugly-but-working version here ...