Refactor PHP rendering to allow different template loading strategies