Made template rendering more reusable