Refactor template code gen to use jinja2

- common changes for review:
  - adds jinja2 to requirements.txt

- 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