Template engine: foreach improved