| 1 |
New features: |
|---|
| 2 |
------------- |
|---|
| 3 |
$Id$ |
|---|
| 4 |
|
|---|
| 5 |
New features in v3.0.0: |
|---|
| 6 |
|
|---|
| 7 |
1. Features |
|---|
| 8 |
----------- |
|---|
| 9 |
The following features are new to patTemplate since version 3.0.0 |
|---|
| 10 |
|
|---|
| 11 |
1.1 Improved reader |
|---|
| 12 |
The reader now accepts tags and data or even several tags in one line. |
|---|
| 13 |
|
|---|
| 14 |
1.2 New architecture |
|---|
| 15 |
patTemplate is now split into several different modules. This allows |
|---|
| 16 |
you to load components at runtime and keep the main codebase small. |
|---|
| 17 |
The available modules are: |
|---|
| 18 |
|
|---|
| 19 |
1.2.1 Reader |
|---|
| 20 |
Splitting the template reader from the main class has several advantages: |
|---|
| 21 |
* Read templeates not only from file but from any datasource. Readers for |
|---|
| 22 |
files and strings have been implemented already. |
|---|
| 23 |
* Read different template types. Currently patTemplate shippes with a reader |
|---|
| 24 |
that is able to read templates that have been created for PEAR's |
|---|
| 25 |
HTML_Template_IT. As PHPLib uses the same template format, it is also possible |
|---|
| 26 |
to work with templates created for the PHPLib templating system. |
|---|
| 27 |
|
|---|
| 28 |
1.2.2 Dump |
|---|
| 29 |
As the dump() functionality is split from the main engine, it increases performance. |
|---|
| 30 |
|
|---|
| 31 |
1.2.3 TemplateCache |
|---|
| 32 |
1.2.4 Input Filter |
|---|
| 33 |
1.2.5 Output Filter |
|---|
| 34 |
1.2.6 Custom Functions |
|---|
| 35 |
1.2.7 Variable Modifiers |
|---|
| 36 |
|
|---|
| 37 |
1.3 New Tags |
|---|
| 38 |
|
|---|
| 39 |
1.3.1 <patTemplate:var/> |
|---|
| 40 |
1.3.2 <patTemplate:comment/> |
|---|
| 41 |
|
|---|
| 42 |
1.4 Modulo Templates |
|---|
| 43 |
Modulo templates are similar to OddEven templates, but you may define how many |
|---|
| 44 |
different sub-templates you need. |
|---|
| 45 |
|
|---|
| 46 |
1.5 Flexible Namespace |
|---|
| 47 |
It's possible to change the namespace of patTemplate, simply |
|---|
| 48 |
use the new method setNamespace() |
|---|
| 49 |
|
|---|
| 50 |
1.6 Several new features for variables |
|---|
| 51 |
|
|---|
| 52 |
1.6.1 <patTemplate:var/> |
|---|
| 53 |
patTemplate 3 introduces the <patTemplate:var/> tag that introduces new |
|---|
| 54 |
features: |
|---|
| 55 |
* default value for a variable |
|---|
| 56 |
* copy the value of a variable |
|---|
| 57 |
* apply a modifier to a variable (PHP function or custom object) |
|---|
| 58 |
* Do not display, but calculate (could be used to count the chars of |
|---|
| 59 |
any variable and store the result in another variable that is |
|---|
| 60 |
used as a condition variable) |
|---|
| 61 |
|
|---|
| 62 |
1.6.2 Multi-dimensional arrays |
|---|
| 63 |
You may now pass a multi-dimensional array to patTemplate and the engine |
|---|
| 64 |
will add the variables in the array to the child-templates. |
|---|
| 65 |
|
|---|
| 66 |
1.7 Support for user-defined tags |
|---|
| 67 |
You may define any tag and register a PHP class that will create the |
|---|
| 68 |
HTML code that will be inserted. |
|---|
| 69 |
|
|---|
| 70 |
1.8 Dynamic includes |
|---|
| 71 |
It is now possible to change the source of an external file at runtime. |
|---|
| 72 |
You'll have to add autoload="off" to the template and then use |
|---|
| 73 |
$tmpl->setAttribute( 'tmpl', 'src', 'myFile.tmpl' ) to change the file that |
|---|
| 74 |
should be included. |
|---|
| 75 |
|
|---|
| 76 |
1.9 Misc other features |
|---|
| 77 |
|
|---|
| 78 |
* new built-in conditions __odd, __even, __first, __last, |
|---|
| 79 |
__default and __empty |
|---|
| 80 |
* new attribute 'addSystemVars' |
|---|
| 81 |
* it's possible to add variables before reading a template |
|---|
| 82 |
prepareTemplate( string tmpl ) must be called for that. |
|---|
| 83 |
* external templates will be loaded when needed |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
2. PHP-API |
|---|
| 87 |
---------- |
|---|
| 88 |
|
|---|
| 89 |
2.1 New methods |
|---|
| 90 |
--------------- |
|---|
| 91 |
|
|---|
| 92 |
2.1.1 patTemplate::addObject( string template, object obj [, string prefix] ) |
|---|
| 93 |
This allows you to add any PHP object to a template. In the template, all |
|---|
| 94 |
properties of the object are available as template variables. |
|---|
| 95 |
Optionally it is possible to specify a prefix. |
|---|
| 96 |
|
|---|
| 97 |
2.1.2 patTemplate::parseIntoVar() |
|---|
| 98 |
|
|---|
| 99 |
2.1.3 patTemplate::setNamespace( string namespace ) |
|---|
| 100 |
Allows you to change the namespace for the patTemplate tags. |
|---|
| 101 |
|
|---|
| 102 |
2.1.4 patTemplate::readTemplatesFromInput() |
|---|
| 103 |
|
|---|
| 104 |
2.1.5 patTemplate::setRoot( string root ) |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
2.2 Deprecated methods |
|---|
| 108 |
---------------------- |
|---|
| 109 |
|
|---|
| 110 |
You should not use the following methods. |
|---|
| 111 |
|
|---|
| 112 |
2.2.1 patTemplate::setBasedir() |
|---|
| 113 |
Please use setRoot() instead. |
|---|
| 114 |
|
|---|
| 115 |
2.2.2 patTemplate::readTemplatesFromFile() |
|---|
| 116 |
Please use readTemplatesFromInput() instead |
|---|