本文整理汇总了Java中org.thymeleaf.TemplateEngine.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateEngine.initialize方法的具体用法?Java TemplateEngine.initialize怎么用?Java TemplateEngine.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.thymeleaf.TemplateEngine
的用法示例。
在下文中一共展示了TemplateEngine.initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.thymeleaf.TemplateEngine; //导入方法依赖的package包/类
/**
* Initialize the Thymeleaf template engine.
*/
@Override
public void init() {
ServletConfig config = this.getServletConfig();
ServletContextTemplateResolver templateresolver = new ServletContextTemplateResolver();
templateresolver.setPrefix(config.getInitParameter(INIT_PARAM_PREFIX));
templateresolver.setSuffix(config.getInitParameter(INIT_PARAM_SUFFIX));
templateresolver.setTemplateMode(config.getInitParameter(INIT_PARAM_TEMPLATEMODE));
templateresolver.setCacheable(false);
templateresolver.setCharacterEncoding(CHARACTER_ENCODING);
templateengine = new TemplateEngine();
templateengine.setTemplateResolver(templateresolver);
Set<IDialect> dialects = new HashSet<IDialect>();
dialects.add(new SpringStandardDialect());
dialects.add(new SqlDialect());
templateengine.setDialects(dialects);
templateengine.initialize();
}
示例2: testJavaScript
import org.thymeleaf.TemplateEngine; //导入方法依赖的package包/类
@Test
public void testJavaScript() {
TemplateEngine engine = createWisdomEngine();
engine.initialize();
Context context = new Context();
context.setVariable("test", "test");
FakeRouter router = new FakeRouter();
Controller controller = new FakeController();
router.addController(controller);
Assets assets = mock(Assets.class);
context.setVariable(Routes.ROUTES_VAR, new Routes(router, assets, controller));
String processed = engine.process("templates/javascript.thl.html", context);
assertThat(processed).containsIgnoringCase("var t = 'test';");
assertThat(processed).containsIgnoringCase("var url = '/';");
assertThat(processed).containsIgnoringCase("$(document).ready(function () {");
}
示例3: init
import org.thymeleaf.TemplateEngine; //导入方法依赖的package包/类
private void init() {
siteFolder = new File(BuilderFolders.SITE);
siteFolder.mkdirs();
TemplateResolver templateResolver = new TemplateResolver();
templateResolver.setResourceResolver(new ProjectResourceResolver());
templateResolver.setSuffix(".html");
templateEngine = new TemplateEngine();
templateEngine.setTemplateResolver(templateResolver);
templateEngine.initialize();
}
示例4: testObjects
import org.thymeleaf.TemplateEngine; //导入方法依赖的package包/类
@Test
public void testObjects() {
FakeContext http = new FakeContext();
http.session().put("value", "session");
http.flash().put("value", "flash");
http.request().data().put("value", "request");
org.wisdom.api.http.Context.CONTEXT.set(http);
TemplateEngine engine = createWisdomEngine();
engine.initialize();
Context context = new Context();
context.setVariable("test", "test");
FakeRouter router = new FakeRouter();
Controller controller = new FakeController();
router.addController(controller);
Assets assets = mock(Assets.class);
context.setVariable(Routes.ROUTES_VAR, new Routes(router, assets, controller));
String processed = engine.process("templates/objects.thl.html", context);
assertThat(processed)
.contains("<span>session</span>")
.contains("<span>flash</span>")
.contains("<span>request</span>");
}