Add support for outputting javascript source of the template.  Fix a bug calling cmd() multiple times from the same program