refact TemplateRenderer and add new feature: layout