[stringtemplate-interest] v4 ST
Graham Wideman
gwlist at grahamwideman.com
Wed Oct 7 20:48:43 PDT 2009
At 10/7/2009 07:53 PM, Terence Parr wrote:
>attributes are injected into the template and *then* it's a evaluated.
>it reinforces idea of push vs pull. :)
>Ter
Ah, right, thanks, you're reminding me of your emphasis on push to enforce separation of data and view issues. And specifically contrasting to other template mechanisms or languages which can grab any application data willy nilly (and possibly cause side-effects given that access).
That said, I think that "injection" is actually overstating the idea when it comes to the actual ST API. The setAttribute method (or whatever it's to be called), actually does not perform the injection of the data into the result, it just makes that data available to the ST object for later insertion where referenced by the template text. Ie: If the template text does not call for that data, then that data doesn't ultimately get rendered into the output.
So this apparatus indeed achieves the effect that you are promoting (the calling app gets to control what data is *permitted* in the output), but that's achieved through a combination of half push (setAttribute) and half pull (reference in template text).
Contrast this to "DOM injection", where chunks of HTML are injected into an existing HTML structure (ie: fragments of html DOM are written into an existing HTML DOM) completely under the contol of an application, with no cooperation or anticipation by the recipient DOM. *That* I think lives up to the word "injection".
The step in the action that's most like "injection", IMO, is the point during toString when template text and attributes get merged together. One might imagine the ST object acting on behalf of the calling app to inject the data, perhaps.
Anyhow, none of this diminishes the attractiveness of the overall ST concept -- just that what sounds good as "inject" at the conceptual intent level maps to a combination of features in the ST implementation, and not one particular method -- in my view.
And whatever that *&^% method is called, I'll still be willing to call it :-).
-- Graham
More information about the stringtemplate-interest
mailing list