Template engine: foreach-bug fixed