In snippets, we have a new possibility to insert the parent content using the
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <opt:extend file="test_inherited_a.tpl"> <opt:snippet name="header"> <h1>Webmaster Of Puppets</h1> <p>Here is the parent content:</p> <opt:parent/> <p>End of the parent content</p> </opt:snippet> </opt:extend>
In this case, if the test_inherited_a.tpl contains another snippet with the same name, its content will be put in the place of
opt:parent. Such nesting works much deeper. For example, let's say that snippet also uses this tag. OPT will try to locate another parent and so on. It is even possible to put the default content of the
opt:insert tag, which is used to place the snippets. The code contains also a simple code to detect the infinite recursion. If the parser finds it, it returns an exception and the programmer sees a nice, red error message :).
During the using of the new OPT, the new debug console should be also useful. It has been extended, compared to the similar option in OPT 1.1.x. The most significant change is splitting the list of templates to the smaller ones which show different information:
- Executed templates
- Currently compiled templates
- Templates read from cache.
- Inherited templates - it shows all the inheritance chains, as well, as the information whether they have been recompiled or not.
Moreover, the console displays all the warnings. They are no longer put onto the screen, but available only with the debug console or error messages, if we set the proper debug level.
The performance issue also looks very good. The total size of opt.class.php file is about 25 KB, compared to 32 KB in the OPT 1.1.x. Currently, its size influences the performance much, as PHP must load the parser and compile it to the internal bytecode. Of course, if we parse a lot of templates, it won't be so visible, however I'm quite pleased of the effect.
The package can be downloaded from here.