Re: template engine...why???
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: template engine...why??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145774@lists.php.net to get a copy of this message | ||
Don't discount the fact that PHP was originally a templating system, and
it still is! My contention is that any general-purpose templating system
will eventually evolve to become PHP because you simply cannot solve all
templating problems without some presentation-level logic and once you add
the first signs of template-level logic, you will eventually turn into
PHP.
You can of course simplify the problem and limit the scope so that you
only address a thin slice of the problem. But you don't really need to
layer a templating system on top of PHP for that. You just need to apply
a little bit of discipline and come up with a sane architecture. Take
this, for example:
http://talks.php.net/presentations/slides/intro/php_app_arch.png
An illustration of using this 4-layer architecture is here:
http://talks.php.net/show/nytips/2
(Yes, I know it looks like crap in IE. View it using Mozilla)
If you can't run Mozilla, you can view the plain PDF version here:
http://lerdorf.com/nytips.pdf
So, please, before you start layering slow templating systems on top of
PHP, have a look at using PHP itself as your templating system. If you
are at all concerned about performance you need to seriously consider an
approach like this.
-Rasmus
On Wed, 30 Apr 2003, Brent Baisley wrote:
> To separate logic & content from design.
>
> Depending on the template system you use, you can separate your PHP
> code from your HTML/CSS/etc. Then you can have a web design expert
> design your pages and you just "plug-in" the content. Or, you could
> allow your client to customize the view if they know HTML. For
> instance, changing the order of columns in a list view, or even which
> columns are displayed.
> By separating you content from the design, you can also easily switch
> display platforms. What if you client wants to access the system from
> their cell phone? With the right template system, you don't have to
> change any of the PHP code you've already done, just the template file
> used to display the data.
>
> I don't use any of the template systems out there since they were much
> more than I needed. I use output buffering (ob_start) to load template
> files into variables and replace (str_replace) custom data tags with
> real data. It's very simple to implement and I can alter a design
> knowing that I won't break my code.
>
> On Tuesday, April 29, 2003, at 09:18 PM, Ryan A wrote:
>
> > Why use a template engine?
> >
> --
> Brent Baisley
> Systems Architect
> Landover Associates, Inc.
> Search & Advisory Services for Advanced Technology Environments
> p: 212.759.6400/800.759.0577
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>