Search in sources :

Example 6 with IModelFactory

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);
}
Also used : IModel(org.thymeleaf.model.IModel) IModelFactory(org.thymeleaf.model.IModelFactory) IStandaloneElementTag(org.thymeleaf.model.IStandaloneElementTag)

Example 7 with IModelFactory

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);
}
Also used : IModel(org.thymeleaf.model.IModel) IModelFactory(org.thymeleaf.model.IModelFactory)

Example 8 with IModelFactory

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);
}
Also used : IModel(org.thymeleaf.model.IModel) IModelFactory(org.thymeleaf.model.IModelFactory)

Example 9 with IModelFactory

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);
}
Also used : IProcessableElementTag(org.thymeleaf.model.IProcessableElementTag) IModelFactory(org.thymeleaf.model.IModelFactory)

Example 10 with IModelFactory

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);
    }
}
Also used : ITemplateEvent(org.thymeleaf.model.ITemplateEvent) IProcessableElementTag(org.thymeleaf.model.IProcessableElementTag) IOpenElementTag(org.thymeleaf.model.IOpenElementTag) IModelFactory(org.thymeleaf.model.IModelFactory) ICloseElementTag(org.thymeleaf.model.ICloseElementTag) IStandaloneElementTag(org.thymeleaf.model.IStandaloneElementTag)

Aggregations

IModelFactory (org.thymeleaf.model.IModelFactory)22 IModel (org.thymeleaf.model.IModel)15 IStandaloneElementTag (org.thymeleaf.model.IStandaloneElementTag)13 IProcessableElementTag (org.thymeleaf.model.IProcessableElementTag)6 AttributeName (org.thymeleaf.engine.AttributeName)1 StandardModelFactory (org.thymeleaf.engine.StandardModelFactory)1 TemplateProcessingException (org.thymeleaf.exceptions.TemplateProcessingException)1 IAttribute (org.thymeleaf.model.IAttribute)1 ICloseElementTag (org.thymeleaf.model.ICloseElementTag)1 IOpenElementTag (org.thymeleaf.model.IOpenElementTag)1 ITemplateEvent (org.thymeleaf.model.ITemplateEvent)1