Templates improvements

I started out just wanting to send out a git patch on a mailing list. The end result is a patchset allowing for in-place template files, and a parser that is probably more robust (at least it doesn't choke on git patches :-) )