Scott Embler 15702ac0d7 Extracted rendering functionality into implementations of HtmlBuilder. (#179)
* Extracted rendering functionality into implementations of HtmlBuilder.

- Two HtmlBuilders are implemented, FlatHtml and IndentedHtml.  Each offers the equivalent output as ContainerTag.render() and ContainerTag.renderFormatted.
- Existing implementations of DomContent/Renderable were updated to support HtmlBuilder where possible.
- Attribute was altered to support the use of TagBuilder.
- Config was altered to allow instances to be created, which can be passed into factory methods for the HtmlBuilders. Config.defaults() can be used for library defaults, while Config.global() can be used for current static configuration.
- Retained compatibility with previous library version as much as possible. See RenderingCompatabilityTest.

* Fixing unchecked or unsafe operations

* Removing unnecessary @param from javadoc.

* Improving casting of HtmlBuilders in implementations of DomContent (tags, text, etc.).

* Preventing NPEs when text is null.

Co-authored-by: Oliver Becker <ob@obqo.de>
2021-05-20 10:47:06 -04:00
2020-08-15 17:34:50 +02:00
2015-10-05 20:19:18 +02:00
2020-08-15 17:34:50 +02:00
2020-08-15 17:38:58 +02:00

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.4.0</version>
</dependency>

Or the gradle dependency

compile 'com.j2html:j2html:1.4.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

Description
Java to HTML generator. Enjoy typesafe HTML generation.
Readme 4.9 MiB
Languages
Java 96.5%
CSS 1.8%
HTML 1.4%
JavaScript 0.3%