Search in sources :

Example 11 with IModelFactory

use of org.thymeleaf.model.IModelFactory in project thymeleaf by thymeleaf.

the class EngineConfiguration method getModelFactory.

public IModelFactory getModelFactory(final TemplateMode templateMode) {
    if (this.modelFactories.containsKey(templateMode)) {
        return this.modelFactories.get(templateMode);
    }
    // TODO The classes to be instanced for creating model factories should be configurable
    final IModelFactory modelFactory = new StandardModelFactory(this, templateMode);
    this.modelFactories.putIfAbsent(templateMode, modelFactory);
    return this.modelFactories.get(templateMode);
}
Also used : StandardModelFactory(org.thymeleaf.engine.StandardModelFactory) IModelFactory(org.thymeleaf.model.IModelFactory)

Example 12 with IModelFactory

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

Example 13 with IModelFactory

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

Example 14 with IModelFactory

use of org.thymeleaf.model.IModelFactory in project thymeleaf-tests by thymeleaf.

the class ReplaceWithNonProcessableCDATASectionProcessor method doProcess.

@Override
protected void doProcess(final ITemplateContext context, final ICDATASection cdataSection, final ICDATASectionStructureHandler 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, false);
}
Also used : IModel(org.thymeleaf.model.IModel) IModelFactory(org.thymeleaf.model.IModelFactory) IStandaloneElementTag(org.thymeleaf.model.IStandaloneElementTag)

Example 15 with IModelFactory

use of org.thymeleaf.model.IModelFactory in project thymeleaf-tests by thymeleaf.

the class ReplaceWithNonProcessableCommentProcessor method doProcess.

@Override
protected void doProcess(final ITemplateContext context, final IComment comment, final ICommentStructureHandler 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, false);
}
Also used : IModel(org.thymeleaf.model.IModel) IModelFactory(org.thymeleaf.model.IModelFactory) 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