fix issue with undefined values in template square brackets