public class MainTemplate { public static String render(String title, Tag... tags) { return document().render() + html().with( head().with( title(title), link().withRel("stylesheet").withHref("/css/main.css") ), body().with( header().with( h1(title) ), main().with( tags //content from other template ), footer().withText("Footer text"), script().withSrc("https://code.jquery.com/jquery-2.1.3.min.js") ) ).render(); } } MainTemplate.render( "Form test", //this is the "String title" parameter //Everything below here goes into the "Tag... tags" parameter // "..." means "varargs", which means you can add as many Tags as you like h2().withText("Please log in"), form().withMethod("post").with( emailInput("Email"), //see below for these three fields passwordInput("Password"), submitButton("Log in") ) // you can create methods like these to return fully configured // HTML input fields/buttons (or any other kind of Tag) public static Tag emailInput(String placeholder) { return input() .withType("email") .withId("email") .withName("email") .withPlaceholder(placeholder) .isRequired(); } public static Tag passwordInput(String placeholder) { return input() .withType("password") .withId("password") .withName("password") .withPlaceholder(placeholder) .isRequired(); } public static Tag submitButton(String text) { return button() .withType("submit") .withText(text); } // OUTPUT (unminified): // // //
//