@Override protected void doProcess(final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { // We are just removing the "<th:block>", leaving whichever contents (body) it might have generated. structureHandler.removeTags(); }
public void process(final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { this.processor.process(context, tag, structureHandler); }
public final MatchingAttributeName getMatchingAttributeName() { return this.processor.getMatchingAttributeName(); }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) { // Nothing to do, this processor is just a marker. Simply remove the attribute final AttributeName attributeName = getMatchingAttributeName().getMatchingAttributeName(); structureHandler.removeAttribute(attributeName); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { if (EvaluationUtils.evaluateAsBoolean(expressionResult)) { StandardProcessorUtils.setAttribute(structureHandler, this.targetAttributeDefinition, this.targetAttributeCompleteName, this.targetAttributeCompleteName); } else { structureHandler.removeAttribute(this.targetAttributeDefinition.getAttributeName()); } }
public static void setAttribute( final IElementTagStructureHandler structureHandler, final AttributeDefinition attributeDefinition, final String attributeName, final String attributeValue) { if (structureHandler instanceof ElementTagStructureHandler) { ((ElementTagStructureHandler) structureHandler).setAttribute(attributeDefinition, attributeName, attributeValue, null); } else { structureHandler.setAttribute(attributeName, attributeValue); } }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { final boolean visible = isVisible(context, tag, attributeName, attributeValue); if (!visible) { structureHandler.removeElement(); } }
@Override protected void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(context.getConfiguration()); final IStandardExpression switchExpression = expressionParser.parseExpression(context, attributeValue); structureHandler.setLocalVariable(SWITCH_VARIABLE_NAME, new SwitchStructure(switchExpression)); }
public StandardDefaultAttributesTagProcessor(final TemplateMode templateMode, final String dialectPrefix) { super(templateMode, PRECEDENCE); this.dialectPrefix = dialectPrefix; this.matchingAttributeName = MatchingAttributeName.forAllAttributesWithPrefix(getTemplateMode(), dialectPrefix); }
public static void replaceAttribute( final IElementTagStructureHandler structureHandler, final AttributeName oldAttributeName, final AttributeDefinition attributeDefinition, final String attributeName, final String attributeValue) { if (structureHandler instanceof ElementTagStructureHandler) { ((ElementTagStructureHandler) structureHandler).replaceAttribute(oldAttributeName, attributeDefinition, attributeName, attributeValue, null); } else { structureHandler.replaceAttribute(oldAttributeName, attributeName, attributeValue); } }
public AbstractElementModelProcessor( final TemplateMode templateMode, final String dialectPrefix, final String elementName, final boolean prefixElementName, final String attributeName, final boolean prefixAttributeName, final int precedence) { super(templateMode, precedence); this.dialectPrefix = dialectPrefix; this.matchingElementName = (elementName == null? null : MatchingElementName.forElementName( templateMode, ElementNames.forName(templateMode, (prefixElementName? this.dialectPrefix : null), elementName))); this.matchingAttributeName = (attributeName == null? null : MatchingAttributeName.forAttributeName( templateMode, AttributeNames.forName(templateMode, (prefixAttributeName? this.dialectPrefix : null), attributeName))); }
public static MatchingAttributeName forAllAttributesWithPrefix(final TemplateMode templateMode, final String matchingAllAttributesWithPrefix) { Validate.notNull(templateMode, "Template mode cannot be null"); // Prefix can actually be null -> match all attributes with no prefix return new MatchingAttributeName(templateMode, null, matchingAllAttributesWithPrefix, false); }
public static MatchingElementName forAllElementsWithPrefix(final TemplateMode templateMode, final String matchingAllElementsWithPrefix) { Validate.notNull(templateMode, "Template mode cannot be null"); // Prefix can actually be null -> match all elements with no prefix return new MatchingElementName(templateMode, null, matchingAllElementsWithPrefix, false); }
public void process(final ITemplateContext context, final IModel model, final IElementModelStructureHandler structureHandler) { this.processor.process(context, model, structureHandler); }
public final MatchingElementName getMatchingElementName() { return this.processor.getMatchingElementName(); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final IElementTagStructureHandler structureHandler) { // Note we are NOT executing the attributeValue as a Standard Expression: we are expecting a literal (see comment above) final IInliner inliner = getInliner(context, StandardInlineMode.parse(attributeValue)); structureHandler.setInliner(inliner); }
public AbstractElementTagProcessor( final TemplateMode templateMode, final String dialectPrefix, final String elementName, final boolean prefixElementName, final String attributeName, final boolean prefixAttributeName, final int precedence) { super(templateMode, precedence); this.dialectPrefix = dialectPrefix; this.matchingElementName = (elementName == null? null : MatchingElementName.forElementName( templateMode, ElementNames.forName(templateMode, (prefixElementName? this.dialectPrefix : null), elementName))); this.matchingAttributeName = (attributeName == null? null : MatchingAttributeName.forAttributeName( templateMode, AttributeNames.forName(templateMode, (prefixAttributeName? this.dialectPrefix : null), attributeName))); }
public static MatchingAttributeName forAllAttributes(final TemplateMode templateMode) { Validate.notNull(templateMode, "Template mode cannot be null"); return new MatchingAttributeName(templateMode, null, null, true); }
public static MatchingElementName forAllElements(final TemplateMode templateMode) { Validate.notNull(templateMode, "Template mode cannot be null"); return new MatchingElementName(templateMode, null, null, true); }
public static MatchingAttributeName forAttributeName(final TemplateMode templateMode, final AttributeName matchingAttributeName) { Validate.notNull(templateMode, "Template mode cannot be null"); Validate.notNull(matchingAttributeName, "Matching attribute name cannot be null"); if (templateMode == TemplateMode.HTML && !(matchingAttributeName instanceof HTMLAttributeName)) { throw new IllegalArgumentException("Attribute names for HTML template mode must be of class " + HTMLAttributeName.class.getName()); } else if (templateMode == TemplateMode.XML && !(matchingAttributeName instanceof XMLAttributeName)) { throw new IllegalArgumentException("Attribute names for XML template mode must be of class " + XMLAttributeName.class.getName()); } else if (templateMode.isText() && !(matchingAttributeName instanceof TextAttributeName)) { throw new IllegalArgumentException("Attribute names for any text template modes must be of class " + TextAttributeName.class.getName()); } return new MatchingAttributeName(templateMode, matchingAttributeName, null, false); }