Re-implement the template resolve() feature