Releases: xmlet/HtmlFlow
htmlflow-3.0
Improved performance. HtmlFlow is on this date the most performant template engine and Java DSL for HTML.
-
Replaced the method
º()
by__()
. -
New static factory methods
view()
of the new classesDynamicHtml
andStaticHtml
-
Removed the static factory methods
html()
,head()
anddiv()
fromHtmlView
. -
Html code is emitted on the fly when the methods of
HtmlApi
(e.g.html()
,div()
,h1()
, etc)
are called. -
Now
HtmlView
is just a container of a template function and anElementVisitor
, which establishes
the HTML output format. -
All emitted HTML is cached.
-
Data binding requires the use of new method
dynamic()
to avoid caching. Otherwise, the context objects are ignored on further renders. -
New method
of()
to enable the use of other methods in the fluent chain. -
New
addPartial()
to enable the reuse of same HTML template function with different HTML fragments. -
Removed the method
binder()
. The role of this method is replaced by the concept of template function which receives the context objectU
that is captured and used whenever is needed, such as indynamic()
.
htmlflow-2.1
HtmlFlow version 2.1 was updated to release 1.0.10 of com.github.xmlet.HtmlApi
and
introduces a couple of new features:
-
New
render()
which produces aString
rather then writing to aPrintStream
. Thisrender()
uses internally aStringBuilder
and shows better performance than thewrite()
approach. -
To allow
HtmlView
being a parent element ofHtml
we madeHtmlView<T>
extendAbstractElement<HtmlView<T>, Element>
and turn it compatible withElement
. Yet, it does not supportaccept(ElementVisitor visitor)
norcloneElem()
. -
Fix
Html root
field definition inHtmlView
to include the generic parent asHtml<HtmlView>
and add it as child of thatHtmlView
. -
New static factory method
html()
used to start building aHtmlView
. -
All these features together with the existing
º()
make possible to build a view in a single pass, reducing the number of auxiliary variables capturing intermediate elements. Now all the views of the examples of thisREADME.md
are built in static fields assignment. More usage examples in HtmlTables and HtmlLists.
htmlflow-2.0
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 an automated framework xmlet based on an XSD definition of the HTML5 syntax and rules.
Thus we remove the package htmlflow.attributes
and htmlflow.elements
, which have been replaced by the types defined in org.xmlet.htmlapi
library. This new approach forces HtmlFlow API to keep consistency along all methods use.
So version 2.0 introduces some changes, namely:
-
All fluent methods have no parameters. For example, formerly when we were specifying the text node of a paragraph or heading (such as,
.p("my text")
or.h2("my title")
), now we have to chain an invocation to thetext()
method (such as,.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 may chain an invocation to
.º()
. For example, formerly when we wrote.div().br().p()
now we have to write.div().br().º().p()
. Moreover the statement.div().br().p()
not even compiles, because HTML does not allow a paragraph inside a break line element, so we will get a compilation error. -
Except for
.text()
which does not create an element but a text node instead, the rest of fluent methods return the created element. For.text()
it returns the element containing the text node (thethis
). -
The new method
º()
returns the parent of an element. This method is strongly typed so it returns exactly an instance ofT
whereT
is the concrete class which extendsElement
. This is an important issue to respect the HTML structure and rules. -
Indentation. Now every element or text node is printed in a new line. Formerly there were some exceptions, namely for text nodes which were printed in the same line of the beginning tag. These exceptions were removed.
-
If you do not like the HtmlFlow print approach you are free to implement your own
org.xmlet.htmlapi.ElementVisitor
. See thehtmlflow.HtmlVisitor
implementation as a guideline. -
Removed default implementation of method
write()
in interfaceHtmlWriter<T>
.