1. A method performed by data processing apparatus, the method comprising: receiving a content item request that includes context data, the context data including at least one of user context data and resource context data, the user context data indicating a user group associated with a user to whom the requested content item will be presented, the resource context indicating a resource on which the content item will be presented; in response to receiving the content item request: identifying a content item that is eligible to be presented in response to the content item request; determining that the content item includes a template variable that is resolved based on the context data; identifying, based on the template variable, a template feed from which a template for the content item is to be selected, the template feed including a set of templates; for each particular template of the template feed: identifying a first performance measure that is based on a performance of the content item when the particular template has been used to create the content item for presentation in response to other content item requests that included a particular user attribute of the user context data; identifying a second performance measure that is based on a performance of other content items when the particular template has been used to create the other content items for presentation with the resource; and determining, for the particular template, a contextual performance measure using the first performance measure and the second performance measure; selecting, from the template feed and based on the contextual performance measure of each template in the template feed, a template for the content item; and populating the selected template with content for the content item to create a formatted content item; and providing the formatted content item in response to the content item request.