Java to HTML generator. Enjoy typesafe HTML generation.
The project webpage is j2html.com.
<dependency>
<groupId>com.j2html</groupId>
<artifactId>j2html</artifactId>
<version>1.0.0</version>
</dependency>
compile 'com.j2html:j2html:1.0.0'
import static j2html.TagCreator.*;
public class Main {
public static void main(String[] args) {
body().with(
h1("Heading!").withClass("example"),
img().withSrc("img/hello.png")
).render();
}
}
The above Java will result in the following HTML:
<body>
<h1 class="example">Heading!</h1>
<img src="img/hello.png">
</body>
Find more examples at http://j2html.com/examples.html