Page 1 of 1

Reviews and suggestions for Open Power Template 2

Posted: Wed May 06, 2009 9:45 am
by Zyxist
Hi everyone,

For almost five years, I've been developing a template engine called "Open Power Template". Currently, I'm finishing the completely new version of the library (2.0), rewritten from scratch and I would like to ask, what do you think about it: any suggestions about the templates, API, features, documentation etc.

Resources

- Project page with the download: http://www.invenzzia.org/en/projects/op ... r-template
- Project documentation: http://static.invenzzia.org/docs/opt/2_0/book/en/ (some minor chapters are still incomplete)
- Online code browser: http://svn.invenzzia.org/browser/OpenPo ... nches/2.0/

Shortly about the project

I've started the project as a part of another project which has been quickly cancelled. Since the beginning I tried to write a template engine that is able to hide most of the template logic implementation details under much simpler "bricks". In OPT 2.0, I've introduced a new philosophy of writing the templates: you say, what you want to have, not - how to implement it and how it is supposed to work. The template compiler does the rest, using well-defined rules of interaction between the instructions. The library has been redesigned from scratch, including the new API based on the frameworks, and true XML language as a base for the template syntax. It also contains various high-level tools, such as components (for form building), sections (true smart loops) or template inheritance. I know that many programmers are against using anything else than PHP for writing the templates, but in this project, I try to find better solutions for the issues, where PHP fails (especially, the form rendering).

The latest available version is 2.0-beta3, and by this weekend, there will appear 2.0-RC1. The library has already got a quite nice popularity in my home country, Poland, but I would like also to know your opinion both about the library and the English-language resources: what should be improved and maybe some hints, how to get with this project to a wider audience outside Poland :).

Re: Reviews and suggestions for Open Power Template 2

Posted: Wed May 06, 2009 11:24 am
by nwhiting
Reading through the documentation I can tell this is well built template engine and supports a lot of great features, and will be helpful to others.

While I speak for myself on this, a template "parsing" engine to be used for PHP while it may be an efficient way of parsing templates, it adds one more step to the process, ( couldn't find any performance tests for this ) a template engine will almost never perform as fast as parsing php itself in templates. Simply because you have to use PHP to parse these templates and the algorithms used can become quite complex when you get into more advanced features, and you must take the extra time to learn the engines syntax.

XML is a great tool for templates but only as a tool to store the structure of templates containing no logic.

http://static.invenzzia.org/docs/opt/2_ ... n.php.html

This page is misleading, using proper development you can built this foreach statement to perform the same exact operation that your template engine does, without a massive list of nested foreach loops, and it will most likely perform much faster because it does not need to do any complex algorithm checks.

With that said, this will be a great tool and helpful to a lot of developers, but because of the complexity and size of many larger scale php applications today, I do not see a template engine being adopted for use with higher-end applications, because parsing template logic with PHP will always outperform a template engine.

Re: Reviews and suggestions for Open Power Template 2

Posted: Wed May 06, 2009 12:18 pm
by Zyxist
Thanks for the review! When it comes to the performance, template engines unsually compile the templates to the pure PHP code, when the original template is modified. Normally, they simply execute the generated PHP file, so that the performance depends on the quality of the generated code and the only addition are the lines that check whether the original template has been modified or not :). Of course, the parsing and the compilation are slow, but they are only done from time to time and almost never in the production environment. In fact, such template engines can be even faster than pure PHP solutions that use advanced OOP, etc. as they can solve some problems during the compilation and the others can be compiled to much simpler PHP code, because it does not have to be easy-to-modify for humans.

Benchmark issue -> there were some benchmarks available for the previous version showing that it was faster than Smarty. For the new one I saw only one that showed that the performance of both OPT 1.x and 2.x is almost the same. Unfortunately, it is written in Polish.