当前位置: 首页>>代码示例>>Java>>正文


Java TemplateEngine.initialize方法代码示例

本文整理汇总了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();
}
 
开发者ID:jmiguelsamper,项目名称:thymeleaf-extras-sqldialect,代码行数:23,代码来源:StandaloneThymeleafServlet.java

示例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 () {");
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:21,代码来源:WisdomTemplateEngineTest.java

示例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();
}
 
开发者ID:javabuild,项目名称:builder-parent,代码行数:11,代码来源:ThymeleafPagesGenerator.java

示例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>");
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:29,代码来源:WisdomTemplateEngineTest.java


注:本文中的org.thymeleaf.TemplateEngine.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。