Java DSL for HTML
HtmlFlow is a Java HTML builder to write typesafe HTML documents in a fluent style, in both Java or Kotlin.
The Java code on the left produces the HTML on the right.
Use the utility Flowifier.fromHtml(html)
to get the HtmlFlow definition from the
corresponding HTML source code.
Flowifier.fromHtml("...")
Flowifier.fromHtml("...")
 
HtmlFlow is the most performant engine among state of the art template engines like Velocity, Thymleaf, Mustache, etc and also other DSL libraries for HTML. Check out the performance results in our forks of the most popular benchmarks at xmlet/template-benchmark and xmlet/spring-comparing-template-engines.
The HTML resulting from HtmlFlow respects all HTML 5.2 rules (e.g. h1().div()
gives a compilation error because it goes against the content
allowed by h1
according to HTML5.2). So, whenever you type .
after an element
the intelissense will just suggest the set of allowed elements and attributes.
The HtmlFlow API is according to HTML5.2 and is generated with the support of an automated framework xmlet based on an XSD definition of the HTML5.2 syntax. Thus, all attributes are strongly typed with enumerated types which restrict the set of accepted values.
References
- 2023, Enhancing SSR in Low-Thread Web Servers, 19th WebIst conference, 2023, Rome - This paper highlights the HtmlFlow templating approach that embraces any asynchronous AP I (e.g., Publisher, promises, suspend functions, flow, etc.) and allows for multiple asynchronous data sources.
- 2020, Text Web Templates Considered Harmful, Part of the Lecture Notes in Business Information Processing book series (LNBIP, volume 399). This paper shows how a DSL for HTML (such as HtmlFlow or Kotlinx.Html) provides unopinionated web templates with boundless resolving features only ruled by the host programming language (such as Java, Kotlin or JavaScript).
- 2019, HoT: Unleash Web Views with Higher-order Templates, 15th WebIst conference, 2019, Viena - This paper highlights the compositional nature of HtmlFlow to compose templates through higher-order functions.
- 2018, Domain Specific Language generation based on a XML Schema - Slides of the MsC thesis presentation of Luís Duarte.
- 2018, Modern Type-Safe Template Engines - You can find more details in this DZone article about performance comparison.