public final class StandardDecoupledTemplateLogicResolver extends Object implements IDecoupledTemplateLogicResolver
Default implementation of the IDecoupledTemplateLogicResolver
interface.
This class computes a ITemplateResource
for the decoupled template logic by resolving a resource considered
relative to the template resource (see ITemplateResource.relative(String)
).
By default, the relative location resolved will be formed as
resource.getBaseName() + DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX (see
ITemplateResource.getBaseName()
and DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX
.
So for a template resource /WEB-INF/templates/main.html, the main.th.xml relative
location will be used to call ITemplateResource.relative(String)
.
However this can be modified by specifying different prefix and suffix values so that, if a prefix with value "../logic/" is specified, for a template resource /WEB-INF/templates/main.html, the ../viewlogic/main.th.xml relative path will be resolved, normally resulting in the /WEB-INF/viewlogic/main.th.xml resource.
This class is thread-safe.
Modifier and Type | Field and Description |
---|---|
static String |
DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX
Default suffix applied to the relative resources resolved: .th.xml
|
Constructor and Description |
---|
StandardDecoupledTemplateLogicResolver() |
Modifier and Type | Method and Description |
---|---|
String |
getPrefix() |
String |
getSuffix() |
ITemplateResource |
resolveDecoupledTemplateLogic(IEngineConfiguration configuration,
String ownerTemplate,
String template,
Set<String> templateSelectors,
ITemplateResource resource,
TemplateMode templateMode)
Resolve an
ITemplateResource object containing the decoupled template logic to be applied to the
template being processed. |
void |
setPrefix(String prefix) |
void |
setSuffix(String suffix) |
public static final String DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX
Default suffix applied to the relative resources resolved: .th.xml
public StandardDecoupledTemplateLogicResolver()
public String getSuffix()
public void setSuffix(String suffix)
public String getPrefix()
public void setPrefix(String prefix)
public ITemplateResource resolveDecoupledTemplateLogic(IEngineConfiguration configuration, String ownerTemplate, String template, Set<String> templateSelectors, ITemplateResource resource, TemplateMode templateMode)
IDecoupledTemplateLogicResolver
Resolve an ITemplateResource
object containing the decoupled template logic to be applied to the
template being processed.
Normally, this decoupled template logic resource will be obtained from the original template's resource itself, but implementations can opt for different mechanisms.
resolveDecoupledTemplateLogic
in interface IDecoupledTemplateLogicResolver
configuration
- the configuration object being used.ownerTemplate
- the owner of the template for which this is being resolved, or null if it is a first-level template.template
- the template for which decoupled logic is being.templateSelectors
- the selectors to be used, defining the fragments that should be processed.resource
- the resource of the resolved template.templateMode
- the template mode to be applied to the resolved template.Copyright © 2016 The THYMELEAF team. All rights reserved.