Overview
Around the end of 2009, I wrote a simple template system for PHP / HTML, which will be used by our designers for websites such as brochures. The purpose of the system is to create templates in otherwise pure HTML through custom tags that are processed by PHP. For example, a template page might look like this:
<tt:Page template="templates/main.html">
<tt:Content name="leftColumn">
<p> blah blah </p>
...
</tt:Content>
<tt:Content name="rightColumn">
<p> blah blah </p>
...
</tt:Content>
</tt:Page>
The template itself may look something like this:
<html>
<head>...</head>
<body>
<div style="float:left; width:45%">
<tt:Container name="leftColumn" />
</div>
<div style="width:45%">
<tt:Container name="rightColumn" />
</div>
</body>
</html>
In addition to the Page and Content / Container tags, there are several other tags included in the kernel for things such as flow control, collection iteration, dynamic value output, etc. The structure is designed so that it is very easy to add your own set of tags registered under a different prefix and namespace.
Custom tags for PHP
? , HTML XML, , XSLT/XPATH, . PHP. PHP- ... , , , " " ( ). , , " ".
, , PHP, ( ):
<?php $tags->push('tt', 'Page', array('template'=>'templates/main.html')); ?>
<?php $tags->push('tt', 'Content', array('name'=>'leftColumn')); ?>
<p> blah blah </p>
...
<?php $tags->pop(); ?>
<?php $tags->push('tt', 'Content', array('name'=>'rightColumn')); ?>
<p> blah blah </p>
...
<?php $tags->pop(); ?>
<?php $tags->pop(); ?>
, eval
, PHP-? . eval , . , , "eval - , ...", , - , eval, ?
, php:// .., , , eval. , , , , .
: ? ?
TIA .:)