Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.edu.uft.util;
- import com.github.mustachejava.DefaultMustacheFactory;
- import com.github.mustachejava.Mustache;
- import com.github.mustachejava.MustacheFactory;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.Reader;
- import java.io.StringReader;
- import java.io.StringWriter;
- import java.util.Map;
- /**
- *
- * @author Thaylon Guedes Santos
- * @email thaylongs@gmail.com
- */
- public class CommonsUtils {
- public static String applyStringTemplate(String templateName, InputStream templateContent, Map<String, Object> scope) {
- return applyStringTemplate(templateName, new InputStreamReader(templateContent), scope);
- }
- public static String applyStringTemplate(String templateName, String templateContent, Map<String, Object> scope) {
- return applyStringTemplate(templateName, new StringReader(templateContent), scope);
- }
- public static String applyStringTemplate(String templateName, Reader templateContent, Map<String, Object> scope) {
- MustacheFactory mf = new DefaultMustacheFactory();
- Mustache mustache = mf.compile(templateContent, templateName);
- StringWriter stringWriter = new StringWriter();
- mustache.execute(stringWriter, scope);
- return stringWriter.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement