templater: factor out runtemplate method
As a side-effect, this makes the output of runmap non-flattened
formatter: improve implementation of data method
This alternate syntax was proposed by Bryan O'Sullivan in a review of
772b3764d3e8. I haven't been able to measure any particular performance
difference, but the new syntax is more concise and easier to read.