variables scoping in templates