use of play.twirl.api.Content in project civiform by seattle-uat.
the class HtmlBundleTest method emptyBundleRendersOutline.
@Test
public void emptyBundleRendersOutline() {
HtmlBundle bundle = new HtmlBundle();
Content content = bundle.render();
assertThat(content.body()).contains("<body><header></header><main></main><div id=\"modal-container\" class=\"hidden fixed" + " h-screen w-screen\"><div id=\"modal-glass-pane\" class=\"fixed h-screen" + " w-screen bg-gray-400 opacity-75\"></div></div><footer></footer></body>");
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class VersionListView method render.
public Content render(List<Version> allVersions, Http.Request request) {
Optional<Version> draftVersion = allVersions.stream().filter(version -> version.getLifecycleStage().equals(LifecycleStage.DRAFT)).findAny();
Optional<Version> activeVersion = allVersions.stream().filter(version -> version.getLifecycleStage().equals(LifecycleStage.ACTIVE)).findAny();
ImmutableList<Version> olderVersions = allVersions.stream().filter(version -> version.getLifecycleStage().equals(LifecycleStage.OBSOLETE)).sorted((a, b) -> a.id.compareTo(b.id)).collect(ImmutableList.toImmutableList()).reverse();
String title = "Program Versions";
HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader("Current Versions"), renderVersionCard(draftVersion), renderVersionCard(activeVersion), renderHeader("Older Versions"), renderPastVersionTable(olderVersions, request));
return layout.renderCentered(htmlBundle);
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class ApplicantLayout method render.
@Override
public Content render(HtmlBundle bundle) {
bundle.addBodyStyles(ApplicantStyles.BODY);
String currentTitle = bundle.getTitle();
if (currentTitle != null && !currentTitle.isEmpty()) {
bundle.setTitle(String.format("%s — %s", currentTitle, CIVIFORM_TITLE));
} else {
bundle.setTitle(CIVIFORM_TITLE);
}
bundle.addFooterStyles(Styles.MT_24);
Content rendered = super.render(bundle);
if (!rendered.body().contains("<h1")) {
logger.error("Page does not contain an <h1>, which is important for screen readers.");
}
if (Strings.countOccurrencesOf(rendered.body(), "<h1") > 1) {
logger.error("Page contains more than one <h1>, which is detrimental to screen readers.");
}
return rendered;
}
use of play.twirl.api.Content in project civiform by seattle-uat.
the class ProgramApplicationView method render.
public Content render(long programId, String programName, long applicationId, String applicantNameWithApplicationId, ImmutableList<Block> blocks, ImmutableList<AnswerData> answers) {
String title = "Program Application View";
ListMultimap<Block, AnswerData> blockToAnswers = ArrayListMultimap.create();
for (AnswerData answer : answers) {
Block answerBlock = blocks.stream().filter(block -> block.getId().equals(answer.blockId())).findFirst().orElseThrow();
blockToAnswers.put(answerBlock, answer);
}
Tag contentDiv = div().withId("application-view").withClasses(Styles.PX_20).with(h2("Program: " + programName).withClasses(Styles.MY_4), h1(applicantNameWithApplicationId).withClasses(Styles.MY_4), renderDownloadButton(programId, applicationId), each(blocks, block -> renderApplicationBlock(programId, block, blockToAnswers.get(block))));
HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(contentDiv);
return layout.render(htmlBundle);
}
use of play.twirl.api.Content in project fess-suggest by codelibs.
the class ApplicationTest method renderTemplate.
@Test
public void renderTemplate() {
Content html = views.html.index.render("Your new application is ready.");
assertThat(contentType(html)).isEqualTo("text/html");
assertThat(contentAsString(html)).contains("Your new application is ready.");
}
Aggregations