Move check if $template has been passed.