TemplateUtil的实现类增加getRawEngine方法

This commit is contained in:
Looly
2022-09-15 00:34:06 +08:00
parent bce8d93ba7
commit f9f0a5ed1a
9 changed files with 150 additions and 61 deletions

View File

@@ -1,5 +1,15 @@
package cn.hutool.extra.template;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.extra.template.engine.thymeleaf.ThymeleafEngine;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.thymeleaf.context.Context;
import org.thymeleaf.standard.StandardDialect;
import org.thymeleaf.templateresolver.StringTemplateResolver;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
@@ -8,23 +18,28 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.thymeleaf.context.Context;
import org.thymeleaf.templateresolver.StringTemplateResolver;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Dict;
import cn.hutool.extra.template.engine.thymeleaf.ThymeleafEngine;
/**
* Thymeleaf单元测试
*
*
* @author looly
*
*/
public class ThymeleafTest {
/**
* <a href="https://github.com/dromara/hutool/issues/2530">...</a>
* 自定义操作原始引擎
*/
@Test
@Ignore
public void addDialectTest(){
final TemplateEngine engine = TemplateUtil.createEngine();
if(engine instanceof ThymeleafEngine){
final org.thymeleaf.TemplateEngine rawEngine = ((ThymeleafEngine) engine).getRawEngine();
rawEngine.addDialect(new StandardDialect());
}
}
@Test
public void thymeleafEngineTest() {
Map<String, Object> map1 = new HashMap<>();