use of org.thymeleaf.model.IProcessableElementTag in project thymeleaf-tests by thymeleaf.
the class ElementStackTextProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IText text, final ITextStructureHandler structureHandler) {
final List<IProcessableElementTag> stack = context.getElementStack();
final StringBuilder stringBuilder = new StringBuilder();
for (final IProcessableElementTag stackTag : stack) {
if (stringBuilder.length() > 0) {
stringBuilder.append(", ");
}
stringBuilder.append(stackTag.getElementCompleteName());
for (final IAttribute attribute : stackTag.getAllAttributes()) {
stringBuilder.append(" ");
stringBuilder.append(attribute.getAttributeCompleteName());
}
}
final String t = text.getText();
structureHandler.setText(t + " " + stringBuilder.toString());
}
use of org.thymeleaf.model.IProcessableElementTag in project thymeleaf-tests by thymeleaf.
the class Attr2ModelAttributeTagProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IModel model, final AttributeName attributeName, final String attributeValue, final IElementModelStructureHandler structureHandler) {
final IModelFactory modelFactory = context.getModelFactory();
final IProcessableElementTag firstEvent = (IProcessableElementTag) model.get(0);
final IProcessableElementTag newFirstEvent = modelFactory.setAttribute(firstEvent, "var2", (String) context.getVariable("var"));
model.replace(0, newFirstEvent);
}
use of org.thymeleaf.model.IProcessableElementTag in project thymeleaf-tests by thymeleaf.
the class ModelAttributeTagProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IModel model, final AttributeName attributeName, final String attributeValue, final IElementModelStructureHandler structureHandler) {
final IModelFactory modelFactory = context.getModelFactory();
final IProcessableElementTag firstEvent = (IProcessableElementTag) model.get(0);
final Map<String, String> attributes = firstEvent.getAttributeMap();
final ITemplateEvent lastEvent = model.get(model.size() - 1);
if (firstEvent == lastEvent) {
final IStandaloneElementTag newFirstEvent = modelFactory.createStandaloneElementTag("ctx", attributes, AttributeValueQuotes.DOUBLE, false, false);
model.replace(0, newFirstEvent);
} else {
final IOpenElementTag newFirstEvent = modelFactory.createOpenElementTag("ctx", attributes, AttributeValueQuotes.DOUBLE, false);
final ICloseElementTag newLastEvent = modelFactory.createCloseElementTag("ctx", false, false);
model.replace(0, newFirstEvent);
model.replace(model.size() - 1, newLastEvent);
}
}
use of org.thymeleaf.model.IProcessableElementTag in project thymeleaf-tests by thymeleaf.
the class MarkupPrintAfterElementModelProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IModel model, final AttributeName attributeName, final String attributeValue, final IElementModelStructureHandler structureHandler) {
final String markupStr = HtmlEscape.escapeHtml4Xml(model.toString().replaceAll("\\r\\n|\\r|\\n", "\\\\n"));
final IModelFactory modelFactory = context.getModelFactory();
final IProcessableElementTag newTag = modelFactory.setAttribute((IProcessableElementTag) model.get(0), "aggafter", markupStr);
model.replace(0, newTag);
}
use of org.thymeleaf.model.IProcessableElementTag in project thymeleaf-tests by thymeleaf.
the class MarkupPrintBeforeElementModelProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IModel model, final AttributeName attributeName, final String attributeValue, final IElementModelStructureHandler structureHandler) {
final String markupStr = HtmlEscape.escapeHtml4Xml(model.toString().replaceAll("\\r\\n|\\r|\\n", "\\\\n"));
final IModelFactory modelFactory = context.getModelFactory();
final IProcessableElementTag newTag = modelFactory.setAttribute((IProcessableElementTag) model.get(0), "aggbefore", markupStr);
model.replace(0, newTag);
}
Aggregations