use of core.framework.impl.template.HTMLTemplate in project core-ng-project by neowu.
the class TemplateManager method get.
private HTMLTemplate get(String templatePath, Class<?> modelClass, String language) {
Map<String, HTMLTemplate> templates = this.templates.get(templatePath);
if (templates == null)
throw Exceptions.error("template is not registered, please use site().template() to add template, templatePath={}", templatePath);
if (webDirectory.localEnv) {
Path path = webDirectory.path(templatePath);
if (Files.lastModified(path).isAfter(templateLastModifiedTimes.get(templatePath))) {
// put modified time first, then template, for zero cost to handle local threading
templateLastModifiedTimes.put(templatePath, Files.lastModified(path));
templates = load(templatePath, modelClass);
this.templates.put(templatePath, templates);
}
}
String targetLanguage = language == null ? MessageImpl.DEFAULT_LANGUAGE : language;
HTMLTemplate template = templates.get(targetLanguage);
if (template == null)
throw Exceptions.error("language is not defined, please check site().message(), language={}", targetLanguage);
return template;
}
Aggregations