Correctly handle unresolved targets in template handler.

* Silly error introduced by incorrect recovery from a null value.

Change-Id: Ibd45047bf181931591c7839d528d004ea9e9cdff