Map<Object, String> templateToClassNameMap, FunctionExecutor globalFunctionExecutor) {
Map<Object, BaseCompiledTemplate> templateMap = new HashMap<Object, BaseCompiledTemplate>();
ClassLoader classLoader = getClass().getClassLoader();
for (Map.Entry<Object, String> entry : templateToClassNameMap.entrySet()) {
String className = entry.getValue();
BaseCompiledTemplate compiledTemplate = loadTemplateObject(className, classLoader);
// Fill in the necessary
compiledTemplate.setFunctionExecutor(globalFunctionExecutor);
compiledTemplate.setTemplateName(entry.getKey().toString());
compiledTemplate.setTemplateLoader(this);
if (entry.getKey() instanceof PrecompiledTemplateMapKey) {
PrecompiledTemplateMapKey mapKey = (PrecompiledTemplateMapKey) entry.getKey();
// The template's escapeMode is not currently used as the autoescaping is all
// handled at compile time. Still set it in case it is needed later on.
compiledTemplate.setEscapeMode(mapKey.getEscapeMode());
} else {
compiledTemplate.setEscapeMode(EscapeMode.ESCAPE_NONE);
}
compiledTemplate.setAutoEscapeOptions(autoEscapeOptions);
templateMap.put(entry.getKey(), compiledTemplate);
}
return ImmutableMap.copyOf(templateMap);
}