Two-stage generation

Added intermediate stage in generation for template to operate on.
Keeps JSON and HTML clean of conditional cocode