本文整理匯總了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>");
}