public class MainTemplate {

    public static String render(String title, Tag... contentTags) {
        return document().render() +
                html().with(
                        head().with(
                                title().withText(title),
                                link().withRel("stylesheet").withHref("/css/main.css")
                        ),
                        body().with(
                                header().with(
                                        h1().withText(title)
                                ),
                                main().with(
                                        contentTags //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... contentTags" 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 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
//  If you call MainTemplate.render with the above setup, it will return this: 
//  <!DOCTYPE html><html><head><title>Form test</title><link rel="stylesheet" href="/css/main.css"></link></head><body><header><h1>Form test</h1></header><main><h2>Please log in</h2><form method="post"><input type="email" id="email" name="email" placeholder="Email" required></input><input type="password" id="password" name="password" placeholder="Password" required></input><button type="submit">Log in</button></form></main><footer>Footer text</footer><script src="https://code.jquery.com/jquery-2.1.3.min.js"></script></body></html>

//  Which unminified will look like this:
//  <!DOCTYPE html>
//  <html>
//  <head>
//     <title>Form test</title>
//     <link rel="stylesheet" href="/css/main.css"></link>
//  </head>
//  
//  <body>
//      <header>
//          <h1>Form test</h1>
//      </header>
//      <main>
//          <h2>Please log in</h2>
//          <form method="post">
//              <input type="email" id="email" name="email" placeholder="Email" required></input>
//              <input type="password" id="password" name="password" placeholder="Password" required></input>
//              <button type="submit">Log in</button>
//          </form>
//      </main>
//      <footer>Footer text</footer>
//      <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
//  </body>
//  </html>

@@ -75,24 +75,17 @@
  Tag... 
-contentT
+t
 ags) %7B%0A 
@@ -622,24 +622,17 @@
         
-contentT
+t
 ags //co
@@ -1050,16 +1050,9 @@
 ... 
-contentT
+t
 ags%22
@@ -1467,17 +1467,25 @@
 y other 
-t
+kind of T
 ag)%0Apubl
@@ -2102,668 +2102,23 @@
 TPUT
-%0A//  If you call MainTemplate.render with the above setup, it will return this: %0A//  %3C!DOCTYPE html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3EForm test%3C/title%3E%3Clink rel=%22stylesheet%22 href=%22/css/main.css%22%3E%3C/link%3E%3C/head%3E%3Cbody%3E%3Cheader%3E%3Ch1%3EForm test%3C/h1%3E%3C/header%3E%3Cmain%3E%3Ch2%3EPlease log in%3C/h2%3E%3Cform method=%22post%22%3E%3Cinput type=%22email%22 id=%22email%22 name=%22email%22 placeholder=%22Email%22 required%3E%3C/input%3E%3Cinput type=%22password%22 id=%22password%22 name=%22password%22 placeholder=%22Password%22 required%3E%3C/input%3E%3Cbutton type=%22submit%22%3ELog in%3C/button%3E%3C/form%3E%3C/main%3E%3Cfooter%3EFooter text%3C/footer%3E%3Cscript src=%22https://code.jquery.com/jquery-2.1.3.min.js%22%3E%3C/script%3E%3C/body%3E%3C/html%3E%0A%0A//  Which unminified will look like this:
+ (unminified):%0A
 %0A// 
@@ -2243,15 +2243,8 @@
 ss%22%3E
-%3C/link%3E
 %0A// 
@@ -2502,32 +2502,24 @@
 l%22 required%3E
-%3C/input%3E
 %0A//         
@@ -2612,16 +2612,8 @@
 red%3E
-%3C/input%3E
 %0A// 

Update MainTemplateExample.java