I'm not so sure. it's a good question. "Template" implies literal content around which dynamic content can be inserted. but what I tend to do is have a "base"class for my application which uses DOM::append_child and DOM::set_attribute methods to set up a "standard content envelope" for the application (*before* any transformation happens). So I guess I'm incorporating template functionality when I "initialise"a page in my app.
Interesting. Like the definition.
My attempt at this is described here although DOM has to get alot more stable (and have a settled API) before I start using something like that in anger.
Code:
<h1>Powered by <phptag id="PHP" /> and <phptag id="MySQL" /></h1>
The markers are the <phptag/> elements which, via DOM, I manipulate in memory. It might be better done something like this though;
Code:
<h1>Powered by <a id="PHP" /> and <a id="MySQL" /></h1>
Also it's probably a bad idea to perform the transformation in memory per page request. Better to parse the "template" with DOM then "compile" into a PHP script containing literal HTML plus PHP code. Something like;
PHP Code:
<h1>Powered by <?php
$PHP = & new Tag('a',$dataSource);
echo $php->render();
?> and <?php
$MySQL = & new Tag('a',$dataSource);
$MySQL->render();
?></h1>
Selkirk's been enlightening me: the Template View - Martin Fowler, in Patterns for Enterprise Application Architecture, describes it as;
Template View: renders information into HTML by embedding markers in an HTML page
Bookmarks