logic if $template is given as string