bug #2906: create arrays for repeated template variables

(cherry picked from commit 571a74aba86f55950438548a1a2c4f151b22b360)