use of play.twirl.api.Content in project deployment-examples by Rookout.
the class FunctionalTest method renderTemplate.
@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.");
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class ProgramAdministratorProgramListView method render.
public Content render(ActiveAndDraftPrograms programs, List<String> authorizedPrograms, Optional<CiviFormProfile> civiformProfile) {
if (civiformProfile.isPresent() && civiformProfile.get().isProgramAdmin() && !civiformProfile.get().isCiviFormAdmin()) {
layout.setOnlyProgramAdminType();
}
String title = "Your programs";
Tag contentDiv = div().withClasses(Styles.PX_20).with(h1(title).withClasses(Styles.MY_4), each(programs.getProgramNames().stream().filter(programName -> authorizedPrograms.contains(programName)).map(name -> this.renderProgramListItem(programs.getActiveProgramDefinition(name), programs.getDraftProgramDefinition(name)))));
HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(contentDiv);
return layout.renderCentered(htmlBundle);
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class ProgramApplicationListView method render.
public Content render(Http.Request request, ProgramDefinition program, PaginationResult<Application> paginatedApplications, Optional<String> search) {
Tag contentDiv = div().withClasses(Styles.PX_20).with(h1(program.adminName()).withClasses(Styles.MY_4), renderPaginationDiv(paginatedApplications.getCurrentPage(), paginatedApplications.getNumPages(), pageNumber -> routes.AdminApplicationController.index(program.id(), search, Optional.of(pageNumber))).withClasses(Styles.MB_2), br(), renderSearchForm(request, search, routes.AdminApplicationController.index(program.id(), Optional.empty(), Optional.empty()), Optional.of(Styles.W_FULL), Optional.of("Search first name, last name, or application ID")).withClasses(Styles.MT_6), each(paginatedApplications.getPageContents(), this::renderApplicationListItem), br(), renderDownloadButton(program.id())).withClasses(Styles.MB_16, Styles.MR_2);
Tag applicationShowDiv = div().withClasses(Styles.W_FULL, Styles.H_FULL).with(iframe().withId("application-display-frame").withClasses(Styles.W_FULL, Styles.H_FULL));
HtmlBundle htmlBundle = layout.getBundle().setTitle(program.adminName() + " - Applications").addFooterScripts(layout.viewUtils.makeLocalJsTag("admin_applications")).addMainStyles(Styles.FLEX).addMainContent(contentDiv, applicationShowDiv);
return layout.renderCentered(htmlBundle);
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class BaseHtmlLayoutTest method addsDefaultContent.
@Test
public void addsDefaultContent() {
HtmlBundle bundle = layout.getBundle();
Content content = layout.render(bundle);
assertThat(content.body()).contains("<!DOCTYPE html><html>");
assertThat(content.body()).contains("<link href=\"/assets/stylesheets/tailwind.css\" rel=\"stylesheet\">");
assertThat(content.body()).contains("<script src=\"/assets/javascripts/main.js\" type=\"text/javascript\"></script>");
assertThat(content.body()).contains("<script src=\"/assets/javascripts/radio.js\" type=\"text/javascript\"></script>");
assertThat(content.body()).contains("<main></main>");
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class HtmlBundleTest method rendersContentInOrder.
@Test
public void rendersContentInOrder() {
HtmlBundle bundle = new HtmlBundle();
bundle.addMainContent(div("One"));
bundle.addMainContent(div("Two"));
Content content = bundle.render();
assertThat(content.body()).contains("<main><div>One</div><div>Two</div></main>");
}
Aggregations