Re: Template engines
| From: | Adam Richardson | Date: | Tue, 09 Nov 2010 18:34:55 +0000 |
| Subject: | Re: Template engines | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309411@lists.php.net to get a copy of this message | ||
On Mon, Nov 8, 2010 at 4:41 PM, Hansen, Mike <Mike.Hansen@atmel.com> wrote:
> I really like the idea of using a templating engine. Which one do you use?
> Why? For those that don't use templating engines, why don't you use them?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I prefer using what essentially amounts to a templating engine, my web
framework, Nephtali. It's markup conventions can be found at the link
below:
http://nephtaliproject.com/documentation/markup/
It helps me easily get things right, for example:
1. Appropriate escaping of output, automatically examining the context to
determine the appropriate form of escaping (html, attribute, or url), or I
can manually declare escaping in the markup to improve performance.
2. When an error occurs in one dynamic region of the page, I don't always
want to show a generic error page (I'd rather just show an error message for
that particular region that experienced an error and show the rest of the
page normally.)
3. I like to progressively enhance pages, and sometimes this involves
grabbing the content of one particular dynamic region of a page. Nephtali
builds in a restful API that allows you to retrieve the content of a dynamic
region instead of retrieving the whole page (the processing short-circuits
to improve performance), for example:
http://nephtaliproject.com/php53hosts/index.php?nmode=htmlfrag&npipe=hosts
4. I like to work on projects with many others of various skill levels
and backgrounds, and the xml comments are easily understood and play nicely
with a broad range of editors/IDE's.
5. Nephtali plays nicely with legacy PHP code, so you can add it to
existing sites without issue (as long as turning on output buffering isn't
an issue.) So, if you want to add some PHP to the page, no problem, you can
have the best of both worlds.
6. Nephtali offers more features (input validation, PDO wrappers, etc.)
and fits within one file, so I get a lot without much ado.
Now, I framed this in terms of my web framework because it's what I know
best. That said, my documentation isn't up to par yet, so it would likely
be frustrating getting up to speed (I did build a code generator to help
out, though.)
Smarty, PHPTAL (I especially appreciate its syntax), and other templating
engines are well documented and offer many of the same features and
qualities, and those features are what compel me to use them as opposed to
just using PHP. That doesn't mean I always use a templating
engine/framework, but I use one much more frequently than not.
Adam
--
Nephtali: PHP web framework that functions beautifully
http://nephtaliproject.com