public class SlingResourceTemplateResolver extends Object implements ITemplateResolver
Constructor and Description |
---|
SlingResourceTemplateResolver() |
Modifier and Type | Method and Description |
---|---|
String |
getName()
Returns the name of this template resolver.
|
Integer |
getOrder()
Return the order in which this template resolver will be executed in the
chain when several template resolvers are set for the same Template Engine.
|
org.thymeleaf.templateresolver.TemplateResolution |
resolveTemplate(org.thymeleaf.IEngineConfiguration engineConfiguration,
org.thymeleaf.context.IContext context,
String ownerTemplate,
String template,
Map<String,Object> templateResolutionAttributes)
Tries to resolve a template.
|
void |
setTemplateModeProvider(TemplateModeProvider templateModeProvider) |
void |
unsetTemplateModeProvider(TemplateModeProvider templateModeProvider) |
public void setTemplateModeProvider(TemplateModeProvider templateModeProvider)
public void unsetTemplateModeProvider(TemplateModeProvider templateModeProvider)
public String getName()
ITemplateResolver
Returns the name of this template resolver. Used in logs and configuration details.
getName
in interface ITemplateResolver
public Integer getOrder()
ITemplateResolver
Return the order in which this template resolver will be executed in the chain when several template resolvers are set for the same Template Engine.
getOrder
in interface ITemplateResolver
public org.thymeleaf.templateresolver.TemplateResolution resolveTemplate(org.thymeleaf.IEngineConfiguration engineConfiguration, org.thymeleaf.context.IContext context, String ownerTemplate, String template, Map<String,Object> templateResolutionAttributes)
ITemplateResolver
Tries to resolve a template.
The method arguments contain all the info needed for trying to
resolve the template. The Template Resolver will apply its configuration
(prefixes/suffixes, template mode patterns, cache configurations, etc) and
return a TemplateResolution
object.
The ownerTemplate, which might be null, will be specified when the template is resolved in order to be used as a fragent to be inserted into a higher level template (the owner). Most template resolver implementations will simply ignore this argument, but others might change their resolution results depending on the owner template that is inserting the resolved fragment.
The fact that a Template Resolver returns a TemplateResolution
does not necessarily
mean that the resolved template resource exists. It might only be so if the template resolver
is configured to perform an existence check on the resource before returning a resolution
result (by means of calling ITemplateResource.exists()
), which might be configurable on
a per-ITemplateResolver
-implementation basis. Implementations might choose not to check
resource existance by default in order to avoid the possible performance impact of a double access
to the resource.
Note that the template selectors that might be used for a executing or inserting a template are not specified to the template resolver. The reason is template selectors are applied by the parser, not the template resolvers, and allowing the resolver to take any decisions based on template selectors (like e.g. omitting some output from the resource) could harm the correctness of the selection operation performed by the parser.
resolveTemplate
in interface ITemplateResolver
engineConfiguration
- the engine configuration.context
- the contextownerTemplate
- the containing template from which we want to resolve a new one as a fragment. Can be null.template
- the template to be resolved (usually its name).templateResolutionAttributes
- the template resolution attributes to be used (usually coming from a
TemplateSpec
instance. Can be null.Copyright © 2007–2017 The Apache Software Foundation. All rights reserved.