@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { if (LOGGER.isWarnEnabled()) { LOGGER.warn( "[THYMELEAF][{}][{}] Deprecated attribute {} found in template {}, line {}, col {}. " + "Please use {} instead, this deprecated attribute will be removed in future versions of Thymeleaf.", new Object[]{ TemplateEngine.threadIndex(), LoggingUtils.loggifyTemplateName(context.getTemplateData().getTemplate()), attributeName, tag.getTemplateName(), Integer.valueOf(tag.getAttribute(attributeName).getLine()), Integer.valueOf(tag.getAttribute(attributeName).getCol()), AttributeNames.forHTMLName(attributeName.getPrefix(), StandardReplaceTagProcessor.ATTR_NAME)}); } super.doProcess(context, tag, attributeName, attributeValue, structureHandler); }
public OutputExpressionInlinePreProcessorHandler( final IEngineConfiguration configuration, final TemplateMode templateMode, final String standardDialectPrefix, final IInlinePreProcessorHandler handler) { super(); this.next = handler; this.standardDialectPrefix = standardDialectPrefix; this.inlineAttributeNames = AttributeNames.forName(templateMode, this.standardDialectPrefix, StandardInlineHTMLTagProcessor.ATTR_NAME).getCompleteAttributeNames(); this.blockElementName = ElementNames.forName(templateMode, this.standardDialectPrefix, StandardBlockTagProcessor.ELEMENT_NAME).getCompleteElementNames()[0].toCharArray(); this.escapedTextAttributeName = AttributeNames.forName(templateMode, this.standardDialectPrefix, StandardTextTagProcessor.ATTR_NAME).getCompleteAttributeNames()[0]; this.unescapedTextAttributeName = AttributeNames.forName(templateMode, this.standardDialectPrefix, StandardUtextTagProcessor.ATTR_NAME).getCompleteAttributeNames()[0]; this.inlineTemplateModes = new TemplateMode[DEFAULT_LEVELS_SIZE]; this.inlineExecLevels = new int[DEFAULT_LEVELS_SIZE]; Arrays.fill(this.inlineTemplateModes, null); Arrays.fill(this.inlineExecLevels, -1); this.inlineIndex = 0; this.execLevel = 0; this.inlineTemplateModes[this.inlineIndex] = templateMode; this.inlineExecLevels[this.inlineIndex] = this.execLevel; this.attributeBuffer = null; }
public void process( final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { final TemplateMode templateMode = getTemplateMode(); final IAttribute[] attributes = tag.getAllAttributes(); // Should be no problem in performing modifications during iteration, as the attributeNames list // should not be affected by modifications on the original tag attribute set for (final IAttribute attribute : attributes) { final AttributeName attributeName = attribute.getAttributeDefinition().getAttributeName(); if (attributeName.isPrefixed()) { if (TextUtil.equals(templateMode.isCaseSensitive(), attributeName.getPrefix(), this.dialectPrefix)) { // We will process each 'default' attribute separately processDefaultAttribute(getTemplateMode(), context, tag, attribute, structureHandler); } } } }
public boolean matches(final AttributeName attributeName) { Validate.notNull(attributeName, "Attributes name cannot be null"); if (this.matchingAttributeName == null) { if (this.templateMode == TemplateMode.HTML && !(attributeName instanceof HTMLAttributeName)) { return false; } else if (this.templateMode == TemplateMode.XML && !(attributeName instanceof XMLAttributeName)) { return false; } else if (this.templateMode.isText() && !(attributeName instanceof TextAttributeName)) { return false; } if (this.matchingAllAttributes) { return true; } if (this.matchingAllAttributesWithPrefix == null) { return attributeName.getPrefix() == null; } final String attributeNamePrefix = attributeName.getPrefix(); if (attributeNamePrefix == null) { return false; // we already checked we are not matching nulls } return TextUtils.equals(this.templateMode.isCaseSensitive(), this.matchingAllAttributesWithPrefix, attributeNamePrefix); } return this.matchingAttributeName.equals(attributeName); }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " + "a \"name\" (or " + Arrays.asList(fieldAttributeName.getCompleteAttributeNames()) + ") attribute " + "with non-empty value in the same host tag.");
final String canonicalAttributeName = attributeName.getAttributeName();
@Override public int hashCode() { return this.attributeName.hashCode(); }
@Override public boolean equals(final Object o) { if (this == o) { return true; } if (!o.getClass().equals(this.getClass())) { return false; } final AttributeDefinition that = (AttributeDefinition) o; if (!this.attributeName.equals(that.attributeName)) { return false; } return true; }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " + "a \"name\" (or " + Arrays.asList(fieldAttributeName.getCompleteAttributeNames()) + ") attribute " + "with non-empty value in the same host tag.");
String canonicalAttributeName = attributeName.getAttributeName();
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " + "a \"name\" (or " + Arrays.asList(fieldAttributeName.getCompleteAttributeNames()) + ") attribute " + "with non-empty value in the same host tag.");
if (firstEvent != null && IProcessableElementTag.class.isAssignableFrom(firstEvent.getClass())) { final String dialectPrefix = attributeName.getPrefix(); final IProcessableElementTag fragmentHolderEvent = (IProcessableElementTag) firstEvent;
@Override public void process(ITemplateContext context, IProcessableElementTag tag, IElementTagStructureHandler structureHandler) { TemplateMode templateMode = getTemplateMode(); IAttribute[] attributes = tag.getAllAttributes(); for (IAttribute attribute : attributes) { AttributeName attributeName = attribute.getAttributeDefinition().getAttributeName(); if (attributeName.isPrefixed()) { if (TextUtil.equals(templateMode.isCaseSensitive(), attributeName.getPrefix(), dialectPrefix)) { processDataAttribute(context, tag, attribute, structureHandler); } } } }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { final AttributeName selectAttrNameToAdd = (AttributeName) context.getVariable(SpringSelectFieldTagProcessor.OPTION_IN_SELECT_ATTR_NAME); if (selectAttrNameToAdd == null) { // Nothing to do return; } // It seems this <option> is inside a <select th:field="...">, and the processor for that "th:field" has left // as a local variable the name and value of the attribute to be added final String selectAttrValueToAdd = (String) context.getVariable(SpringSelectFieldTagProcessor.OPTION_IN_SELECT_ATTR_VALUE); if (tag.hasAttribute(selectAttrNameToAdd)) { if (!selectAttrValueToAdd.equals(tag.getAttributeValue(selectAttrNameToAdd))) { throw new TemplateProcessingException( "If specified (which is not required), attribute \"" + selectAttrNameToAdd + "\" in " + "\"option\" tag must have exactly the same value as in its containing \"select\" tag"); } } // This attribute value does not need to be escaped, because we are just "transporting" the th:field in the // container <select> to its <option>'s, without any modifications. It will be executed (and its results // escaped) later... structureHandler.setAttribute(selectAttrNameToAdd.getCompleteAttributeNames()[0], selectAttrValueToAdd); }
String canonicalAttributeName = attributeName.getAttributeName();
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " + "a \"name\" (or " + Arrays.asList(fieldAttributeName.getCompleteAttributeNames()) + ") attribute " + "with non-empty value in the same host tag.");
public void setAttributeDefinitions(final AttributeDefinitions attributeDefinitions) { Validate.notNull(attributeDefinitions, "Attribute Definitions cannot be null"); // We precompute the AttributeDefinitions in order to being able to use much // faster methods for setting/replacing attributes on the ElementAttributes implementation final String dialectPrefix = getMatchingAttributeName().getMatchingAttributeName().getPrefix(); this.targetAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TARGET_ATTR_NAME); this.fieldAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, dialectPrefix, AbstractSpringFieldTagProcessor.ATTR_NAME); this.typeAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, TYPE_ATTR_NAME); this.nameAttributeDefinition = attributeDefinitions.forName(TEMPLATE_MODE, NAME_ATTR_NAME); }
@Override public void process(ITemplateContext context, IProcessableElementTag tag, IElementTagStructureHandler structureHandler) { TemplateMode templateMode = getTemplateMode(); IAttribute[] attributes = tag.getAllAttributes(); for (IAttribute attribute : attributes) { AttributeName attributeName = attribute.getAttributeDefinition().getAttributeName(); if (attributeName.isPrefixed()) { if (TextUtil.equals(templateMode.isCaseSensitive(), attributeName.getPrefix(), dialectPrefix)) { processDataAttribute(context, tag, attribute, structureHandler); } } } }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { final AttributeName selectAttrNameToAdd = (AttributeName) context.getVariable(SpringSelectFieldTagProcessor.OPTION_IN_SELECT_ATTR_NAME); if (selectAttrNameToAdd == null) { // Nothing to do return; } // It seems this <option> is inside a <select th:field="...">, and the processor for that "th:field" has left // as a local variable the name and value of the attribute to be added final String selectAttrValueToAdd = (String) context.getVariable(SpringSelectFieldTagProcessor.OPTION_IN_SELECT_ATTR_VALUE); if (tag.hasAttribute(selectAttrNameToAdd)) { if (!selectAttrValueToAdd.equals(tag.getAttributeValue(selectAttrNameToAdd))) { throw new TemplateProcessingException( "If specified (which is not required), attribute \"" + selectAttrNameToAdd + "\" in " + "\"option\" tag must have exactly the same value as in its containing \"select\" tag"); } } // This attribute value does not need to be escaped, because we are just "transporting" the th:field in the // container <select> to its <option>'s, without any modifications. It will be executed (and its results // escaped) later... structureHandler.setAttribute(selectAttrNameToAdd.getCompleteAttributeNames()[0], selectAttrValueToAdd); }
if (bindStatus == null) { final AttributeName fieldAttributeName = AttributeNames.forHTMLName(attributeName.getPrefix(), AbstractSpringFieldTagProcessor.ATTR_NAME); throw new TemplateProcessingException( "Cannot apply \"" + attributeName + "\": this attribute requires the existence of " + "a \"name\" (or " + Arrays.asList(fieldAttributeName.getCompleteAttributeNames()) + ") attribute " + "with non-empty value in the same host tag.");