templater: unroll loop over mapfile directories
I'll rewrite the handling of the templatedir() case in the next
patch, so the two cases will be more different and the loop won't make
as much sense.
Differential Revision: https://phab.mercurial-scm.org/D8895