use of org.thymeleaf.model.IModelFactory in project thymeleaf-tests by thymeleaf.
the class ReplaceWithProcessableXMLDeclarationProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext context, final IXMLDeclaration xmlDeclaration, final IXMLDeclarationStructureHandler structureHandler) {
final IModelFactory modelFactory = context.getModelFactory();
final IStandaloneElementTag tag = modelFactory.createStandaloneElementTag("replaced", "th:text", "one", false, true);
final IModel model = modelFactory.createModel(tag);
structureHandler.replaceWith(model, true);
}
use of org.thymeleaf.model.IModelFactory in project thymeleaf-tests by thymeleaf.
the class Dialect02Div2Processor method doProcess.
@Override
protected void doProcess(final ITemplateContext processingContext, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) {
final IModelFactory modelFactory = processingContext.getModelFactory();
final IModel markup = modelFactory.createModel();
markup.add(modelFactory.createText("[From Dialect 02-2]"));
structureHandler.insertBefore(markup);
}
use of org.thymeleaf.model.IModelFactory in project thymeleaf-tests by thymeleaf.
the class Dialect02DivProcessor method doProcess.
@Override
protected void doProcess(final ITemplateContext processingContext, final IProcessableElementTag tag, final IElementTagStructureHandler structureHandler) {
final IModelFactory modelFactory = processingContext.getModelFactory();
final IModel markup = modelFactory.createModel();
markup.add(modelFactory.createText("[From Dialect 02]"));
structureHandler.insertImmediatelyAfter(markup, true);
}
use of org.thymeleaf.model.IModelFactory 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.IModelFactory 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);
}
}
Aggregations