Fixed handling of carets ("^") in template names

Change-Id: Ic5dea45359c89243bd73f05d45dbce6902b7ffbc