Skip to content

tipsy/j2html

Folders and files

NameName
Last commit message
Last commit date
Dec 26, 2022
Aug 15, 2020
Jun 30, 2022
Dec 26, 2022
Dec 26, 2022
Dec 26, 2022
Dec 26, 2022
Dec 2, 2017
Oct 17, 2020
Dec 26, 2022
Dec 26, 2022
Oct 5, 2015
Jun 30, 2022
Dec 2, 2017
Apr 24, 2021
Aug 15, 2020
Dec 26, 2022

Repository files navigation

Workflow

j2html

Java to HTML generator. Enjoy typesafe HTML generation.

The project webpage is j2html.com.

Getting started

Add the maven dependency

<dependency>
    <groupId>com.j2html</groupId>
    <artifactId>j2html</artifactId>
    <version>1.6.0</version>
</dependency>

Or the gradle dependency

compile 'com.j2html:j2html:1.6.0'

Import TagCreator and start building HTML

import static j2html.TagCreator.*;

public class Main {
    public static void main(String[] args) {
        body(
            h1("Hello, World!"),
            img().withSrc("/img/hello.png")
        ).render();
    }
}

The above Java will result in the following HTML:

<body>
    <h1>Hello, World!</h1>
    <img src="/img/hello.png">
</body>

Find more examples at http://j2html.com/examples.html