本文整理汇总了Java中play.twirl.api.Content类的典型用法代码示例。如果您正苦于以下问题:Java Content类的具体用法?Java Content怎么用?Java Content使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Content类属于play.twirl.api包,在下文中一共展示了Content类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import play.twirl.api.Content; //导入依赖的package包/类
@Override
public CompletionStage<Content> render(final PageContent pageContent, @Nullable final String templateName, @Nullable final String cmsKey) {
final PageData pageData = pageDataFactory.create(pageContent);
return hookRunner.waitForHookedComponentsToFinish()
.thenComposeAsync(unused -> {
PageDataReadyHook.runHook(hookRunner, pageData);
logFinalPageData(pageData);
return super.render(pageData, templateName, cmsKey);
}, HttpExecution.defaultContext());
}
示例2: renderTemplate
import play.twirl.api.Content; //导入依赖的package包/类
@Test
@Ignore
public void renderTemplate() {
// If you are calling out to Assets, then you must instantiate an application
// because it makes use of assets metadata that is configured from
// the application.
Content html = views.html.index.render("Your new application is ready.");
assertThat("text/html").isEqualTo(html.contentType());
assertThat(html.body()).contains("Your new application is ready.");
}
示例3: renderTest
import play.twirl.api.Content; //导入依赖的package包/类
@Test
public void renderTest() {
running(fakeApplication(), () -> { // runnable
Content html = views.html.index.render("", null);
assertEquals("text/html", html.contentType());
// email label
assertTrue(contentAsString(html).contains(Messages.get("index.text.email")));
// password label
assertTrue(contentAsString(html).contains(Messages.get("index.text.password")));
// on index is video
assertTrue(contentAsString(html).contains("flex-video"));
// registration link
assertTrue(contentAsString(html).contains(Messages.get("index.text.registration") + "</a>"));
});
}
示例4: renderTemplate
import play.twirl.api.Content; //导入依赖的package包/类
@Test
public void renderTemplate() {
// If you are calling out to Assets, then you must instantiate an application
// because it makes use of assets metadata that is configured from
// the application.
Content html = views.html.index.render("Your new application is ready.");
assertThat("text/html").isEqualTo(html.contentType());
assertThat(html.body()).contains("Your new application is ready.");
}
示例5: render
import play.twirl.api.Content; //导入依赖的package包/类
protected CompletionStage<Content> render(final PageData pageData, @Nullable final String templateName, @Nullable final String cmsKey) {
if (cmsKey != null) {
return cmsService.page(cmsKey, userLanguage.locales())
.thenApplyAsync(cmsPage -> renderHtml(pageData, templateName, cmsPage.orElse(null)), HttpExecution.defaultContext());
} else {
return completedFuture(renderHtml(pageData, templateName, null));
}
}
示例6: renderLogin
import play.twirl.api.Content; //导入依赖的package包/类
@Test
public void renderLogin() {
final Form<Login> loginForm = form (Login.class).fill (new Login (null));
Content html = views.html.login.render(loginForm);
assertThat(Helpers.contentType(html)).isEqualTo("text/html");
assertThat(Helpers.contentAsString(html)).contains(Domain.message("web.application.title"));
assertThat(Helpers.contentAsString(html)).contains(Domain.message("web.application.login"));
}
示例7: render
import play.twirl.api.Content; //导入依赖的package包/类
protected Content render(String template, Parameters params) {
Content content;
try {
content = call(templatePackageName + template, "render", params);
} catch (ClassNotFoundException | MethodNotFoundException e) {
if (log.isDebugEnabled())
log.debug("template not found : '" + template + "'");
return templateNotFound(template, params);
}
return content;
}
示例8: templateNotFound
import play.twirl.api.Content; //导入依赖的package包/类
protected Content templateNotFound(String template, Parameters params) {
StringBuilder sb = new StringBuilder("Template ");
sb.append(templatePackageName).append(template).append("(");
Class<?>[] types = params.types();
for (int i = 0; i < types.length; i++) {
Class<?> type = types[i];
if (i != 0)
sb.append(", ");
sb.append(type.getSimpleName());
}
sb.append(") is not found");
return Html.apply(sb.toString());
}
示例9: render
import play.twirl.api.Content; //导入依赖的package包/类
@Override
protected Content render(String template, Parameters params) {
Content content;
try {
content = call(templatePackageName + template, "render", params);
} catch (ClassNotFoundException | MethodNotFoundException e) {
if (log.isDebugEnabled())
log.debug("template not found : '" + template + "'");
throw new TemplateNotFoundException();
}
return content;
}
示例10: renderList
import play.twirl.api.Content; //导入依赖的package包/类
@Override
protected Content renderList(Page p) {
try {
return super.renderList(p);
} catch (TemplateNotFoundException e) {
// use dynamic template
if (log.isDebugEnabled())
log.debug("Rendering dynamic LIST template for model : " + model);
return play.utils.crud.views.html.list.render(model, model.getFields().values(), p);
}
}
示例11: renderForm
import play.twirl.api.Content; //导入依赖的package包/类
protected Content renderForm(Object key, Form form) {
if (log.isDebugEnabled())
log.debug("renderForm <- form:" + form);
try {
return super.renderForm(key, form);
} catch (TemplateNotFoundException e) {
// use dynamic template
if (log.isDebugEnabled())
log.debug("Rendering dynamic FORM template for model : " + model);
return play.utils.crud.views.html.edit.render(model, model.getFields().values(), key, form);
}
}
示例12: renderShow
import play.twirl.api.Content; //导入依赖的package包/类
@Override
protected Content renderShow(BasicModel modelObject) {
try {
return super.renderShow(modelObject);
} catch (TemplateNotFoundException e) {
// use dynamic template
if (log.isDebugEnabled())
log.debug("Rendering dynamic SHOW template for model : " + model);
return play.utils.crud.views.html.show.render(model, model.getFields().values(), modelObject);
}
}
示例13: renderTemplate
import play.twirl.api.Content; //导入依赖的package包/类
@Test
public void renderTemplate() {
Content html = views.html.index.render("Your s3proxy application is ready.");
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("Your s3proxy application is ready.");
}
示例14: renderTemplate
import play.twirl.api.Content; //导入依赖的package包/类
@Test
public void renderTemplate() {
Content html = views.html.index.render("Your new application is ready.");
assertEquals("text/html", html.contentType());
assertTrue(html.body().contains("Your new application is ready."));
}
示例15: unauthorized
import play.twirl.api.Content; //导入依赖的package包/类
/** Diplay the normal login form if HTTP authentication fails */
@Override
protected Content unauthorized(Context context) {
return login.render(this.auth, this.userProvider, this.LOGIN_FORM);
}