return parser.parseTemplate(r);
}
private Resource locateTemplateResource(ComponentModel initialModel, Locale locale)
{
ComponentModel model = initialModel;
while (model != null)
{
Resource baseResource = baseResourceForModel(model);
Resource localized = baseResource.forLocale(locale);
// In a race condition, we may hit this method a couple of times, and overwrite previous
// results with identical new results.
// If found a properly localized version of the base resource for the model,
// then we've found a match (even if we had to ascend a couple of levels
// to reach it).
if (localized != null) return localized;
// Not on the classpath, the the locator see if its a) a page and b) a resource inside
// the context
localized = locator.findPageTemplateResource(model, locale);
if (localized != null) return localized;
// Otherwise, this component doesn't have its own template ... lets work up to its
// base class and check there.
model = model.getParentModel();
}
// This will be a Resource whose URL is null, which will be picked up later and force the
// return of the empty template.