Re: Template system in PHP
| From: | Nathan Nobbe | Date: | Tue, 12 Feb 2008 21:51:46 +0000 |
| Subject: | Re: Template system in PHP | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269211@lists.php.net to get a copy of this message | ||
On Feb 12, 2008 4:45 PM, Robert Cummings <robert@interjinn.com> wrote:
> > well thats what xslt is, which is pretty nice.
>
> Nah, I don't bother with XSLT.
i know, i just thought id mention it, since xml was brought up and nobodys
even mentioned xslt yet.
i will likely move away from xslt, but i will be doing something different
than
the straight php based templating, like in code igniter. thats great for
simple
projects, but the thing i hate the most is escaping in and out of php, bleh!
im still experimenting w/ my solution so i wont bother to share it until its
worth
looking at, but for the meantime the basic php mechanism is suitable.
and i certainly dont use eval()! its slow and it opens holes to attacks.
the most simple, way to template w/ php is w/ php, very simply, you will
have a
file, blah.php
and watch how i include another 'template' after the data portion, (the
second template
is blah2.php
<someHtmlTag>
<?=$someDataFromPhp?>
<?php include('blah2.php'); ?>
</someOtherHtmlTag>
and there you have it, that is the most direct way to template w/ php,
backed by the
language itself. there is no need for eval either. i have my reasons for
not liking it,
but as i said, my system is far from ready and well this is cleaner than
writing functions
with strings, thats just horrid, imho.
whwe, rant finished :)
-nathan