/** * <p> * Returns the template name of the first-level template. * </p> * <p> * Note this template name refers to the first-level one, the one used to call the TemplateEngine itself, even * if by the moment this method is called the engine is processing a fragment inserted from the first-level * template (or at any other level in the hierarchy). * </p> * * @return the template name */ public String getProcessedTemplateName() { return this.context.getTemplateStack().get(0).getTemplate(); }
final String ownerTemplate = ownerTemplateData.getTemplate(); (templateMode != null? templateMode : ownerTemplateData.getTemplateMode()); (useCache && ownerTemplateData.getValidity().isCacheable()? AlwaysValidCacheEntryValidity.INSTANCE : NonCacheableCacheEntryValidity.INSTANCE); new TemplateData( ownerTemplateData.getTemplate(), ownerTemplateData.getTemplateSelectors(), ownerTemplateData.getTemplateResource(), templateMode, cacheValidity)); final ITemplateParser parser = getParserForTemplateMode(templateData.getTemplateMode());
final String template = templateData.getTemplate(); final ITemplateResource templateResource = templateData.getTemplateResource(); final boolean templateCacheable = templateData.getValidity().isCacheable();
final String ownerTemplate = context.getTemplateData().getTemplate(); final Map<String,Object> templateResolutionAttributes = context.getTemplateResolutionAttributes(); final ITemplateParser parser = getParserForTemplateMode(templateData.getTemplateMode()); parser.parseStandalone( this.configuration, ownerTemplate, template, cleanTemplateSelectors, templateData.getTemplateResource(), templateData.getTemplateMode(), templateResolution.getUseDecoupledLogic(), builderHandler);
public final TemplateMode getTemplateMode() { return this.templateData.getTemplateMode(); }
null, template, templateSelectors, templateData.getTemplateResource(), engineContext.getTemplateMode(), templateResolution.getUseDecoupledLogic(), builderHandler); null, template, templateSelectors, templateData.getTemplateResource(), engineContext.getTemplateMode(), templateResolution.getUseDecoupledLogic(), processingHandlerChain);
public boolean checkIsValueStillValid( final TemplateCacheKey key, final TemplateModel value, final long entryCreationTimestamp) { return value.getTemplateData().getValidity().isCacheStillValid(); }
private static TemplateData buildTemplateData( final TemplateResolution templateResolution, final String template, final Set<String> templateSelectors, final TemplateMode templateMode, final boolean useCache) { final TemplateMode definitiveTemplateMode = (templateMode == null ? templateResolution.getTemplateMode() : templateMode); final ICacheEntryValidity definitiveCacheEntryValidity = (useCache? templateResolution.getValidity() : NonCacheableCacheEntryValidity.INSTANCE); return new TemplateData( template, templateSelectors, templateResolution.getTemplateResource(), definitiveTemplateMode, definitiveCacheEntryValidity); }
if (this.insertOnlyContents && fragmentTemplateData.hasTemplateSelectors()) {
/** * <p> * Returns the template mode ({@link TemplateMode}) of the first-level template. * </p> * <p> * Note this template mode refers to the first-level one, the one used to call the TemplateEngine itself, even * if by the moment this method is called the engine is processing a fragment inserted from the first-level * template (or at any other level in the hierarchy). * </p> * * @return the template mode */ public TemplateMode getProcessedTemplateMode() { return this.context.getTemplateStack().get(0).getTemplateMode(); }
parser.parseStandalone( this.configuration, null, template, templateSelectors, templateData.getTemplateResource(), engineContext.getTemplateMode(), templateResolution.getUseDecoupledLogic(), builderHandler); final TemplateModel templateModel = builderHandler.getModel();
/** * <p> * Returns the template name (of the leaf template). * </p> * <p> * Note that the template name returned here corresponds with origin of the elements or nodes being * currently processed. This is, if a processor is being executed for an element inserted from an external * template (via a {@code th:insert}, for example), then this method will return the template mode * for the template in which the inserted fragment lives, not the one it was inserted into. * </p> * * @return the template name */ public String getTemplateName() { return this.context.getTemplateData().getTemplate(); }
public final TemplateMode getTemplateMode() { return getTemplateData().getTemplateMode(); }
/** * <p> * Returns the names of all the stack of templates appliable to the current point * of execution. This will depend on which templates are inserted inside wich. * </p> * <p> * The first-level template will appear first, and the most specific template will appear last. * </p> * * @return the stack of template names */ public List<String> getTemplateNames() { final List<TemplateData> templateStack = this.context.getTemplateStack(); final List<String> templateNameStack = new ArrayList<String>(templateStack.size()); for (final TemplateData templateData : templateStack) { templateNameStack.add(templateData.getTemplate()); } return templateNameStack; }
/** * <p> * Returns the template mode ({@link TemplateMode}) (of the leaf template). * </p> * <p> * Note that the {@link TemplateMode} returned here corresponds with origin of the elements or nodes being * currently processed. This is, if a processor is being executed for an element inserted from an external * template (via a {@code th:insert}, for example), then this method will return the template mode * for the template in which the inserted fragment lives, not the one it was inserted into. * </p> * * @return the template mode */ public TemplateMode getTemplateMode() { return this.context.getTemplateData().getTemplateMode(); }
@Override public String toString() { final Map<String,Object> equivalentMap = new LinkedHashMap<String, Object>(); final Enumeration<String> attributeNamesEnum = this.request.getAttributeNames(); while (attributeNamesEnum.hasMoreElements()) { final String name = attributeNamesEnum.nextElement(); equivalentMap.put(name, this.request.getAttribute(name)); } final String textInliningStr = (getInliner() != null? "[" + getInliner().getName() + "]" : "" ); final String templateDataStr = "(" + getTemplateData().getTemplate() + ")"; return equivalentMap.toString() + (hasSelectionTarget()? "<" + getSelectionTarget() + ">" : "") + textInliningStr + templateDataStr; }
/** * <p> * Returns the {@link TemplateMode}s of all the stack of templates appliable to the current point * of execution. This will depend on which templates are inserted inside wich. * </p> * <p> * The first-level template will appear first, and the most specific template will appear last. * </p> * * @return the stack of template modes */ public List<TemplateMode> getTemplateModes() { final List<TemplateData> templateStack = this.context.getTemplateStack(); final List<TemplateMode> templateModeStack = new ArrayList<TemplateMode>(templateStack.size()); for (final TemplateData templateData : templateStack) { templateModeStack.add(templateData.getTemplateMode()); } return templateModeStack; }
strBuilder.append("(").append(this.templateDatas[n].getTemplate()).append(")");
private TemplateModel applyPreProcessorsIfNeeded(final ITemplateContext context, final TemplateModel templateModel) { final TemplateData templateData = templateModel.getTemplateData(); if (this.configuration.getPreProcessors(templateData.getTemplateMode()).isEmpty()) { return templateModel; } final IEngineContext engineContext = EngineContextManager.prepareEngineContext(this.configuration, templateData, context.getTemplateResolutionAttributes(), context); final ModelBuilderTemplateHandler builderHandler = new ModelBuilderTemplateHandler(this.configuration, templateData); final ITemplateHandler processingHandlerChain = createTemplateProcessingHandlerChain(engineContext, true, false, builderHandler, null); templateModel.process(processingHandlerChain); EngineContextManager.disposeEngineContext(engineContext); return builderHandler.getModel(); }
@Override public String toString() { final Map<String,Object> equivalentMap = new LinkedHashMap<String, Object>(); int n = this.index + 1; int i = 0; while (n-- != 0) { if (this.maps[i] != null) { final List<String> entryNames = new ArrayList<String>(this.maps[i].keySet()); Collections.sort(entryNames); for (final String name : entryNames) { final Object value = this.maps[i].get(name); if (value == NON_EXISTING) { equivalentMap.remove(name); continue; } equivalentMap.put(name, value); } } i++; } final String textInliningStr = (getInliner() != null? "[" + getInliner().getName() + "]" : "" ); final String templateDataStr = "(" + getTemplateData().getTemplate() + ")"; return equivalentMap.toString() + (hasSelectionTarget()? "<" + getSelectionTarget() + ">" : "") + textInliningStr + templateDataStr; }