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

org.noear.solon.view.velocity.RenderUtil Maven / Gradle / Ivy

There is a newer version: 3.0.5-M3
Show newest version
package org.noear.solon.view.velocity;

import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import java.io.StringWriter;
import java.util.Map;

public class RenderUtil {
    static VelocityEngine engine = null;

    public static String render(String template, Map model) throws Exception {

        if (engine == null) {
            engine = new VelocityEngine();
            engine.init();
        }
        VelocityContext context = new VelocityContext(model);

        StringWriter writer = new StringWriter();

        engine.evaluate(context, writer, "", template);

        return writer.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy