當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。