j2html 1.6.0 adds support for web components and newer HTML elements. (Jun 2022)
j2html 1.6.0 is available for download on Maven Central.
Changes:
- Added
TagCreator::data
to provide machine-readable translations. - Added
TagCreator::picture
to provide alternative versions of an image for different display/device scenarios. - Added
TagCreator::slot
to provide placeholders for web components. - Added
TagCreator::template
to provide templating of content fragments for web components. - Added global attributes used for web components.
j2html 1.5.0 enhances factory methods and class types, overhauls HTML rendering, introduces support for Java modules and fixes several bugs (Jun 2021)
j2html 1.5.0 is available for download on Maven Central.
This version contains breaking changes. Please view the upgrade guide.
Changes:
- Added
Automatic-Module-Name
to manifest to support JDK 9+ - Added
TagCreator::each(DomContent...)
- Added
TagCreator::each(Collection, BiFunction)
- Added
HtmlBuilder
interface, with implementations for FlatHtml
and IndentedHtml
- Added
Config.defaults()
for customizable configuration instances and Config.global()
for (backwards-compatible) static global configuration - Deprecated old rendering methods. Libraries that use custom Tag implementations should switch to using
HtmlBuilder
- Fixed the use of
rawHtml()
when constructing the Tag tree - Fixed text escaping for
style()
and script()
- Fixed formatting of children for
textarea()
and pre()
- Fixed appending an unnecessary delimiter to the end of text with
join()
- Thanks to Oliver Becker for many code improvements
j2html 1.4.0 adds a couple of convenient methods (Jan 2019)
j2html 1.4.0 is available for download on Maven Central.
Changes:
- Added
TagCreator::each(Map, BiFunction)
- Added
Stream<DomContent>
variants of each
and with
j2html 1.3.0 has a couple of features and fixes (May 2018)
j2html 1.3.0 is available for download on Maven Central.
Changes:
- Added support for
Map
in each()
- Added osgi metadata
- Added support for
Optional
in iff()
- Fixed bugs in
renderFormatted()
j2html 1.2.2 has performance improvements (Dec 2017)
j2html 1.2.2 is available for download on Maven Central.
Changes:
- There have been some massive performance improvements. Big thanks to kicktipp.
j2html 1.2.1 fixes some bugs (Nov 2017)
j2html 1.2.1 is available for download on Maven Central.
Changes:
- Fix "bad closing tag (<!DOCTYPE html/>) when closeEmptyTags is true" bug
- Fix "can't load static resources from jar" bug
- Fix "CSSMin stripping last character of CSS rule if rule doesn't end in semi-colon" bug
j2html 1.2.0 already? (Sep 2017)
j2html 1.2.0 is available for download on Maven Central.
Changes:
- Added option to render formatted HTML, ex
body(...).renderFormatted()
- Added option to configure HTML-formatting-indent via
Config.indenter = (int, string) -> {...}
- Added option to configure CSS-minification via
Config.cssMinifier = string -> {...}
- Added option to configure JS-minification via
Config.jsMinifier = string -> {...}
- Added option to close empty tags via
Config.closeEmptyTags = true
attr()
can now take take any object, not just strings
j2html 1.1.0 is out! (Aug 2017)
j2html 1.1.0 is available for download on Maven Central.
Changes:
- Added a option to customize TextEscaper via
Config.textEscaper = text -> {}
j2html 1.0.0 is here! (May 2017)
j2html 1.0.0 is available for download on Maven Central.
Changes:
- v1 is officially done. We will be doing semantic versioning from now on.
- All tag methods (
div()
, p()
etc ) can now accept an arbitrary number of DomContent
as arguments, eliminating the need for with()
in most cases. - Added a shorthand-attribute overloads to all TagCreator methods:
div(attrs("#id.class")
becomes <div id="id" class="class"></div>
- Added a
join()
method to more easily join sentences with inline HTML, like:
join("Added a", code("join()"), "method to more ea...
- Added a
document()
method that takes a html()
tag and renders a HTML declaration followed by the html content - Added support for Java 7 and Java 6. Some functionality (each/filter) will not work on these versions, but everything else should.
j2html 0.99 released! (Apr 2017)
j2html 0.99 is available for download on Maven Central.
Changes:
- Added generic
iff()
/ iffElse()
methods for performing if's in method calls. - Added
withClasses()
to add multiple classes to element. Works well with iff()
. - HTML-escaping is now a lot faster (and a lot faster than StringUtils)
- Static files can now be fetched from anywhere, not just classpath
j2html 0.88 released! (Jan 2017)
j2html 0.88 is available for download on Maven Central.
Changes:
- Closure and StringUtils dependencies removed in favor of custom implementations. Most users seem interested in a very lightweight library.
unsafeHtml()
- is now
rawHtml()
- Added
.equals()
- to Tag-class. Two Tags are equal if they render the same HTML
j2html 0.7 released!
j2html 0.7 is available for download on Maven Central.
Changes:
- New file-api (avilable from TagCreator class):
- fileAsString(String path)
- returns a file's content as a String (useful for including static HTML such as Google Analytics code)
- fileAsEscapedString(String path)
- returns fileAsString(path) escaped (useful for including the code-examples on this website)
- styleWithInlineFile(String path)
- returns <style>fileAsString(path)</style>
- styleWithInlineFile_min(String path)
- returns <style>fileAsString(path)</style>, minimized using CSSMin
- scriptWithInlineFile(String path)
- returns <script>fileAsString(path)</script>
- scriptWithInlineFile_min(String path)
- returns <script>fileAsString(path)</script>, minimized using Google Closure
- Java 7 support (j2html previously only worked with Java 8)
- Use apache stringutils for escaping
j2html 0.5.0 is on Maven! (Late May 2015)
j2html 0.5.0 is available for download on Maven Central.
We've finished the herculean task of releasing on Maven Central.