Refactoring to enable injecting the templator