tpl: fixed several regexps related to spaces in {foreach and {if
tpl unit tests uncommented
tpl: regexps upgraded, unit tests improved