Eager vs Lazy HTML building
masterHtmlFlow supports two approaches for building HTML, depending on when the Appendable (the output destination) is provided:
Eager Approach
The Appendable is provided immediately. Use HtmlFlow.doc(Appendable).
Java Example:
HtmlFlow.doc(System.out).html().body().h1().text("Welcome").__()...Lazy Approach
The template is defined first, and the Appendable is provided later during rendering. Use HtmlFlow.view(Function).
This is more performant when binding the same template to different data models because static HTML blocks are resolved only once during instantiation.
Java Example:
var view = HtmlFlow.<Model>view(page -> page.html().body().text("Welcome").__()...);
// Rendering:
String html = view.render(model);
// Or writing to an Appendable:
view.setOut(System.out).write(model);// Eager
HtmlFlow.doc(System.out).html().body().h1().text("Welcome").__();
// Lazy
var view = HtmlFlow.<Model>view(page -> page.html().body().text("Welcome").__());
String html = view.render(model);