check for template output target existence more robustly