HtmlFlow
HtmlFlow copied to clipboard
Make newby() return structureless ElementVisitor
The core org.xmlet.htmlapifaster.ElementVisitor
implementation in HtmlFlow
is the class HtmlVisitorCache
(which in turn should drop the sufix Cache
, because caching it is not its real purpose but only storing static HTML blocks instead).
The internal field cacheBlocksList
(that should also replace the word cache
by static
) is useless when we are computing a partial view (i.e. fragment) with a model, because calling for example view.addPartial(penguimPartialView, penguin)))
will always create a new visitor from v.newbie()
in partial.clone(v.newbie()).render(model);
. Thus the static blocks stored internally will not be reused.
So, in this case the newbie()
should return an instance of an alternative implementation of ElementVisitor
similar to HtmlVisitor
but that emits HTML without storing the static parts (e.g. ElementVisitorUnstatic
).
The hierarchy should be refactored. Now it is like:
HtmlVisitorPrintStream
----|>
HtmlVisitorCache
-------|>
ElementVisitor
Maybe it will turn in:
HtmlVisitorDynamicPrintStream --------------|> HtmlVisitorDynamic ----|> AbstractHtmlVisitor -------|> ElementVisitor
|
HtmlVisitorPrintStream ---------------------|> HtmlVisitor -----------|