xmlet/HtmlFlow

Make newby() return structureless ElementVisitor

fmcarvalho opened this issue · 1 comments

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 -----------|

No more need it. newbie() was removed and there is a completely new approach for using partials.