Refactor template code gen to use jinja2

- replace "".format with jinja2
- refactor code-inlined templates to be in files
- refactor template lookups to use inheritance
  - removes some duplicated template code
  - also a first step to generalizing grappalang 

- [ ] merge #358 first