Class StandardDecoupledTemplateLogicResolver
- Object
-
- org.thymeleaf.templateparser.markup.decoupled.StandardDecoupledTemplateLogicResolver
-
- All Implemented Interfaces:
IDecoupledTemplateLogicResolver
public final class StandardDecoupledTemplateLogicResolver extends Object implements IDecoupledTemplateLogicResolver
Default implementation of the
IDecoupledTemplateLogicResolverinterface.This class computes a
ITemplateResourcefor the decoupled template logic by resolving a resource considered relative to the template resource (seeITemplateResource.relative(String)).By default, the relative location resolved will be formed as
resource.getBaseName() + DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX(seeITemplateResource.getBaseName()andDECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX. So for a template resource/WEB-INF/templates/main.html, themain.th.xmlrelative location will be used to callITemplateResource.relative(String).However this can be modified by specifying different
prefixandsuffixvalues so that, if aprefixwith value"../logic/"is specified, for a template resource/WEB-INF/templates/main.html, the../viewlogic/main.th.xmlrelative path will be resolved, normally resulting in the/WEB-INF/viewlogic/main.th.xmlresource.This class is thread-safe.
- Since:
- 3.0.0
- Author:
- Daniel Fernández
-
-
Field Summary
Fields Modifier and Type Field Description static StringDECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIXDefault suffix applied to the relative resources resolved: ".th.xml"
-
Constructor Summary
Constructors Constructor Description StandardDecoupledTemplateLogicResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetPrefix()StringgetSuffix()ITemplateResourceresolveDecoupledTemplateLogic(IEngineConfiguration configuration, String ownerTemplate, String template, Set<String> templateSelectors, ITemplateResource resource, TemplateMode templateMode)Resolve anITemplateResourceobject containing the decoupled template logic to be applied to the template being processed.voidsetPrefix(String prefix)voidsetSuffix(String suffix)
-
-
-
Field Detail
-
DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX
public static final String DECOUPLED_TEMPLATE_LOGIC_FILE_SUFFIX
Default suffix applied to the relative resources resolved: ".th.xml"
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSuffix
public String getSuffix()
-
setSuffix
public void setSuffix(String suffix)
-
getPrefix
public String getPrefix()
-
setPrefix
public void setPrefix(String prefix)
-
resolveDecoupledTemplateLogic
public ITemplateResource resolveDecoupledTemplateLogic(IEngineConfiguration configuration, String ownerTemplate, String template, Set<String> templateSelectors, ITemplateResource resource, TemplateMode templateMode)
Description copied from interface:IDecoupledTemplateLogicResolverResolve an
ITemplateResourceobject 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.
- Specified by:
resolveDecoupledTemplateLogicin interfaceIDecoupledTemplateLogicResolver- Parameters:
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.- Returns:
- the resource containing the decoupled template logic, or
nullif there isn't any.
-
-