CPPSERV


Home Projects Jobs Clientele Contact

cppserv


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Food for thought on subject of templates



Am Freitag, 6. Januar 2006 02:48 schrieb Ilya A. Volynets-Evenbakh:
> There are two approaches to the way templates act:
> 1. Template is main thing - it creates/retrieves objects, calls their
> methods, etc.
>     It has access to request and responce objects, and to the resto
> environment throught them.
>     JSP-like, from what I understand.
> 2. Alternatively template could be "secondary" - i.e. there is some sort
> of object, that
>     performs whatever it needs to, then gets hold of template, binds
> data to template
>     variables, and then sends results to output. This is what Velocity
> engine does.
>
> I personally like second one better - it seems to force separation of
> code and presentation
> more. However, I'd like to hear other opinions.

I think the best approach is not to bind users to anything. Just let the user 
decide.

In JSP-like environments (as Tntnet has) you can put a object in request-scope 
and call the template, which just prints, what it finds in this object. Also 
there is at least one add-ons to JSP, which act more like your 2nd type: JSF.

It would be possible to create a applicationframework on top of a 
templateengine of your first type, which acts like the 2nd.

Tommi

Authoright © Total Knowledge: 2001-2008