private Template findAndCacheTemplate(TemplateVariableBinding pageScope, String templateName,
String contextPath, String pluginName, final String uri) throws IOException {
String templatePath = GrailsStringUtils.isNotEmpty(contextPath) ? GrailsResourceUtils.appendPiecesForUri(contextPath, templateName) : templateName;
final GroovyPageScriptSource scriptSource;
if (pluginName == null) {
scriptSource = groovyPageLocator.findTemplateInBinding(templatePath, pageScope);
} else {
scriptSource = groovyPageLocator.findTemplateInBinding(pluginName, templatePath, pageScope);
}
String cacheKey;
if (scriptSource == null) {
cacheKey = contextPath + pluginName + uri;
} else {
cacheKey = scriptSource.getURI();
}
return CacheEntry.getValue(templateCache, cacheKey, reloadEnabled ? GroovyPageMetaInfo.LASTMODIFIED_CHECK_INTERVAL : -1, null,
new Callable<CacheEntry<Template>>() {
public CacheEntry<Template> call() {