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

cn.hutool.extra.template.engine.jetbrick.JetbrickTemplate Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.extra.template.engine.jetbrick;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.extra.template.AbstractTemplate;
import jetbrick.template.JetTemplate;

import java.io.OutputStream;
import java.io.Serializable;
import java.io.Writer;
import java.util.Map;

/**
 * Jetbrick模板实现
* 见:https://github.com/subchen/jetbrick-template-2x * * @author looly * @since 5.7.21 */ public class JetbrickTemplate extends AbstractTemplate implements Serializable{ private static final long serialVersionUID = 1L; private final JetTemplate rawTemplate; /** * 包装Jetbrick模板 * * @param jetTemplate Jetbrick的模板对象 {@link JetTemplate } * @return JetbrickTemplate */ public static JetbrickTemplate wrap(JetTemplate jetTemplate) { return (null == jetTemplate) ? null : new JetbrickTemplate(jetTemplate); } /** * 构造 * * @param jetTemplate Jetbrick的模板对象 {@link JetTemplate } */ public JetbrickTemplate(JetTemplate jetTemplate) { this.rawTemplate = jetTemplate; } @Override public void render(Map bindingMap, Writer writer) { final Map map = Convert.convert(new TypeReference>() {}, bindingMap); rawTemplate.render(map, writer); } @Override public void render(Map bindingMap, OutputStream out) { final Map map = Convert.convert(new TypeReference>() {}, bindingMap); rawTemplate.render(map, out); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy