All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.resource4j.thymeleaf3.Resource4jTemplateEngine Maven / Gradle / Ivy

package com.github.resource4j.thymeleaf3;

import org.thymeleaf.*;
import org.thymeleaf.context.IContext;

import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Resource4jTemplateEngine implements ITemplateEngine {

    private ITemplateEngine engine;

    public Resource4jTemplateEngine(ITemplateEngine engine) {
        this.engine = engine;
    }

    @Override
    public IEngineConfiguration getConfiguration() {
        return engine.getConfiguration();
    }

    @Override
    public String process(String template, IContext context) {
        Map attributes = new HashMap<>();
        attributes.put("locale", context.getLocale());
        return engine.process(new TemplateSpec(template, attributes), context);

    }

    @Override
    public String process(String template, Set templateSelectors, IContext context) {
        return engine.process(template, templateSelectors, context);
    }

    @Override
    public String process(TemplateSpec templateSpec, IContext context) {
        return engine.process(templateSpec, context);
    }

    @Override
    public void process(String template, IContext context, Writer writer) {
        Map attributes = new HashMap<>();
        attributes.put("locale", context.getLocale());
        engine.process(new TemplateSpec(template, attributes), context, writer);
    }

    @Override
    public void process(String template, Set templateSelectors, IContext context, Writer writer) {
        engine.process(template, templateSelectors, context, writer);
    }

    @Override
    public void process(TemplateSpec templateSpec, IContext context, Writer writer) {
        engine.process(templateSpec, context, writer);
    }

    @Override
    public IThrottledTemplateProcessor processThrottled(String template, IContext context) {
        Map attributes = new HashMap<>();
        attributes.put("locale", context.getLocale());
        return engine.processThrottled(new TemplateSpec(template, attributes), context);
    }

    @Override
    public IThrottledTemplateProcessor processThrottled(String template, Set templateSelectors, IContext context) {
        return engine.processThrottled(template, templateSelectors, context);
    }

    @Override
    public IThrottledTemplateProcessor processThrottled(TemplateSpec templateSpec, IContext context) {
        return engine.processThrottled(templateSpec, context);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy