Test for definedness of route.template, not truthiness.

Otherwise we fail to set $template when the template is the empty string.