Reduce duplicated code in resource tmpl