RE: [PHP Template] Template Discussion
[email protected] ("Peter Kocks") Wed, 22 Mar 2000 10:45:10 -0800
| Newsgroups | php.template |
|---|---|
| Message-ID | <[email protected]> |
Perhaps I missed something earlier, and if I did, I
apologize, but it seems to me that the goal of providing
template functionality is to create a mechanism by which
non-php coders (designers) could easily put together part of
a web page using HTML and some tags for inserting php code.
Yes?
If so, I don't see why this cannot be done with php directly
and a simple use of here-docs. The template would be a here
doc that gets incorporated by php wherever it needs to:
Here is an example:
File called designer.tmp:
---------------------------------------
print <<< END;
<HTML>
The current date is $date <p>
A table containing customers follows:<p>
{$cust.table()}
</HTML>
END;
---------------------------------------
A php program would set $date equal to the current date and
create an object called "cust" with a method called table()
that would print out a table listing customers. It would
then do an include of designer.tmp. I'm not sure the
{$cust.table()} syntax will work, but I can't see any reason
that it should not.
To make things even easier, one could create a php function
called template(filename) that, like include, would load a
file but it would treat it as a here doc.
The only thing missing that I see is conditionals, but if
you're going down that route, you're probably in php land
anyway.
my 3 cents worth...
--pk