call getTemplate inside anonymous function so that it's only evaluated on route run