News for hackers. Stuff that matters.
Re:String Templating Considered Harmful by lhorie on Monday March 24, 2014 @01:00PM (#7459392)
> This AST is later combined with data (typically plain old JavaScript objects, or POJOs) to construct a lightweight data-bound ‘parallel DOM’, which can run in the browser or on the server. Through this, it is able to make smart decisions about how to update the real DOM in the most conservative manner possible.

> Because it only touches the parts of the DOM it needs to, you can write your templates in the way that makes the most sense for your app, without having to worry about the performance headaches of constantly trashing the DOM or the code headache of wiring up a plethora of view objects.

Huh, the solution he described is basically the technique I use in Mithril[1], except that Mithril templates don't need the extra HTML parsing step because they pretty much are the AST.

My bare-bones approach received some criticism here last week for not being "pretty" (for the "HTML is pretty" definition of "pretty"), but it allows better debuggability[2], and opens the doors for some interesting FP techniques, among other things.

Templating seems to be a hot button these days, but it's unfortunate that it's such a complex topic. Discussions about performance like this article are great, but it's hard for non-framework devs to keep all the other facets of template design in their heads when trying to evaluate the bazillion choices in the market.

[1] http://lhorie.github.io/mithril/

[2] https://github.com/lhorie/mithril.js/issues/16

There are no comments on this comment yet.