use of org.thymeleaf.templatemode.TemplateMode in project sling by apache.
the class SlingResourceTemplateResolver method resolveTemplate.
@Override
public TemplateResolution resolveTemplate(final IEngineConfiguration engineConfiguration, final IContext context, final String ownerTemplate, final String template, final Map<String, Object> templateResolutionAttributes) {
logger.debug("resolving template '{}'", template);
if (context instanceof SlingContext) {
final SlingContext slingContext = (SlingContext) context;
final ResourceResolver resourceResolver = slingContext.getResourceResolver();
final Resource resource = resourceResolver.getResource(template);
if (resource == null) {
logger.warn("resource for template '{}' is null, not resolving template", template);
return null;
}
final ITemplateResource templateResource = new SlingTemplateResource(resource);
final boolean templateResourceExistenceVerified = false;
final TemplateMode templateMode = templateModeProvider.provideTemplateMode(resource);
if (templateMode == null) {
logger.warn("template mode for template '{}' is null, not resolving template", template);
return null;
} else {
logger.debug("using template mode {} for template '{}'", templateMode, template);
final boolean useDecoupledLogic = templateMode.isMarkup() && configuration.useDecoupledLogic();
final ICacheEntryValidity validity = NonCacheableCacheEntryValidity.INSTANCE;
return new TemplateResolution(templateResource, templateResourceExistenceVerified, templateMode, useDecoupledLogic, validity);
}
} else {
logger.error("context is not an instance of SlingContext");
return null;
}
}
Aggregations