Base refactor for search templates.