Re: [SMARTY-DEV] Var Templates
| From: | Patrick Emond | Date: | Wed, 16 Apr 2003 09:29:19 +0000 |
| Subject: | Re: [SMARTY-DEV] Var Templates | ||
| References: | 1 2 3 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1184@lists.php.net to get a copy of this message | ||
On Wed, 2003-04-16 at 02:59, Wom.bat wrote:
> I think you two didn't get the purpose of a template engine like Smarty.
> Smarty's purpose is to seperate APPLICATION(!) from PRESENTATION(!) _LOGIC_
> (!).
> That means that you prepare RAW content in PHP, and everything else is done
> by Smarty.
> You DONT format the date in PHP, you give a pure UNIX timestamp to Smarty
> instead, which then displays it in the correct format using the date_format
> modifier (which is, by the way, indispensable, if you want for example
> multilingual sites, as date and time in germany are formatted different than
> in the united states than in great britain).
> You DONT tell smarty which message to print, instead you write all messages
> into the template, and then give Smarty a status code and use an IF
> construct to resolve the correct message
> You DONT let PHP create URLs, this is done in the template
> ... etc etc
That is one way to use Smarty, however it isn't the only way.
> The magic rule is not to have ANY html, not even something like
> "left|center|right" to pass to an align atribute, in PHP. Same rule for ANY
> messages (yes, the E-Mails sent by your application should be created with
> templates, too) etc. A good way to seperate cleanly is always to bear in
> mind that it should be possible to create the same website with a COMPLETELY
> different layout (not only colors and graphics, but also positioning of
> elements etc) without needing to change even ONE single line of PHP code.
> THAT'S the purpose of Smarty.
Actually that's precisely what I'm using Smarty for. My applications
are written so that if some other form of markup is necessary all that
is needed is another template - WML, XML or even RTF, it's still all
seperation of markup from logic. Perhaps you misunderstood my comments?
> You are using it like a simple template engine which can only replace vars
> and handle very simple loops... in my opinion, that's wrong.
> Nobody forces you to use Smarty, if you think, it's too overloaded, you are
> free to try another template engine - I bet you'd return to Smarty after 10
> minutes.
As I mentioned in my first email, I very much like Smarty and I don't
have any problems with it. I was simply adding my feelings to what
boots said as a programmer interested in the development of Smarty.
It's my opinion (and remains so), not an attack on how other people use
Smarty or anything else.
> And I don't think that performance could be increased greatly by creating a
> "Smarty Lite"... I bet it would only be 10% faster, or even less...
> Regards,
> David
>
> ----- Original Message -----
> From: "Patrick Emond" <patrickemond@softhome.net>
> To: <smarty-dev@lists.php.net>
> Sent: Wednesday, April 16, 2003 3:11 AM
> Subject: Re: [SMARTY-DEV] Var Templates
>
>
> > I've been using Smarty for about 1 1/2 years and never looked back
> > since, I am very happy with everything it has to offer and it covers all
> > my markup-logic separation needs.
> >
> > About the only thing I can complain about with Smarty is that it tries
> > to do too much. I completely agree with boots and his comments, Smarty
> > (for me at least) is used to separate all markup from logic as much as
> > possible - not perform logic. About the only template functions I use
> > are if, section and include and rarely any others. It's not that the
> > other functionality isn't useful, it's just that some seem completely
> > superfluous to php's own very excellent logic handling.
> >
> > If Smarty will be moving more in the direction of doing-it-all as it
> > seems to be then would it make sense to release a smarty-lite version
> > that concentrates on performance instead of functionality? Just a
> > thought.
> >
> > Patrick
> >
> > On Wed, 2003-04-16 at 00:09, boots wrote:
> > > Hi all.
> > >
> > > FWIW, I've been casually following the long discussion on backticks and
> > > automatically expanding vars as if they were themselves templates. I
> > > think it was Tom Sommer who initiated that discussion, but if not, he
> > > certainly has put a lot of interesting details on the table.
> > >
> > > One thing I am uncertain of is the need for such a thing in the base
> > > Smarty engine. From Monte Ohrt's comments, it looks like this type of
> > > change has potential to wreak havoc with performance and in the end,
> > > I'm not sure why anyone would REALLY need this feature--at least in the
> > > engine core. There are two issues I'm concerned about:
> > >
> > > 1) there seems to be a push to program general COMPUTATION using the
> > > template facility instead of PHP code. I'm -1 on that because I think
> > > that as much as possible, logic should be handled in the PHP code.
> > > Otherwise your templates aren't really templates, are they? In other
> > > words, if you want to evaluate a var using templates and then use that
> > > value in another template, you should probably do the first evaluation
> > > in PHP and pass the results to the second template. Both your code and
> > > your templates are likely to be a bit more stable in that case.
> > >
> > > 2) I want the base Smarty to stay as minimally small (and fast!) as
> > > possible. IMHO, anything that can be implemented effeciently using the
> > > Smarty API (ie. plugins, resources, filters) should be factored out of
> > > the engine.
> > >
> > > For example, the functionality that Tom is talking about can likely be
> > > created using a custom Resource. I posted a very simple Global Var
> > > template reader to the Wiki back in september that shows how to go
> > > about doing a similar thing (it would have to be expanded to meet Tom's
> > > criteria). The point is, is that there is a LOT of room to extend
> > > functionality without trying to shoehorn everything into the core. This
> > > is especially true for the more abstract and escoteric features that we
> > > developers sometimes crave :).
> > >
> > > xo boots
> > >
> > > __________________________________________________
> > > Do you Yahoo!?
> > > The New Yahoo! Search - Faster. Easier. Bingo
> > > http://search.yahoo.com
> > --
> > Patrick Emond <patrickemond@softhome.net>
> >
> >
> > --
> > Smarty Development Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--
Patrick Emond <patrickemond@softhome.net>