Release 2.0
· 2 min read
HtmlFlow version 2.0 has full support for all existing HTML5 elements and attributes. Moreover all attributes are strongly typed with enumerated types which restrict accepted values.
Now HtmlFlow API is constructed with the support of the automated framework xmlet based on an XSD definition of the HTML5 syntax and rules.
Thus we remove the packages htmlflow.attributes and htmlflow.elements,
which have been replaced by the types defined in the org.xmlet.htmlapi library.
This new approach forces the HtmlFlow API to maintain consistency across all method use.
Version 2.0 introduces the following changes:
- All fluent methods have no parameters. For example, formerly when specifying the text node of a paragraph or heading (
.p("my text")or.h2("my title")), we now chain an invocation to thetext()method (.p().text("my text")or.h2().text("my title")). - All fluent methods now return the created element. Whenever we need to proceed with the parent element, we chain an invocation to
.º(). For example, instead of.div().br().p(), we now write.div().br().º().p(). Moreover,.div().br().p()will no longer compile because HTML does not allow a paragraph inside a break line element. - Except for
.text(), which creates a text node instead of an element, the rest of the fluent methods return the created element. For.text(), it returns the element containing the text node (this). - The new method
º()returns the parent of an element. This method is strongly typed to return an instance ofT, whereTis the concrete class extendingElement. This ensures compliance with HTML structure and rules. - Indentation is updated so every element or text node is printed on a new line, removing previous exceptions where text nodes were printed on the same line as the opening tag.
- Custom implementations of
org.xmlet.htmlapi.ElementVisitorare supported for those who prefer a different printing approach. See thehtmlflow.HtmlVisitorimplementation as a guideline. - The default implementation of the
write()method in theHtmlWriter<T>interface has been removed.