Fixes issue 6990. This uses a bit of templating to remove the duplicate code that is the CodeBlocks in each emitter headers. No actual functionality change in this.