Invenzzia » Projects / Open Power Libraries / Open Power Template / Overview


Open Power Template is a powerful XML-based template engine for PHP5. Contrary to many other template engines and PHP itself, OPT aims to provide declarative tools for presentation layer designers. It means that you do not have to worry, how all those things are supposed to work and co-operate with the script. You must only tell what you want to get and OPT will do the rest for you.

It has been developed for three years so far. Currently, we are working on a new version written from scratch. It has a better design, performance and lots of new features. You can see it by downloading one of the development releases and watching the examples and test files. This library is created for you, so we encourage to send your opinions, feature requests, found bugs and even your own code snippets. We would like the library to suit your needs and cooperation is the best way to achieve this.

The most important template engine task is the HTML code generation that is sent to the visitor browsers. We think that both pure PHP and many other similar projects complicate this process to much or focus on strange things and priorities. The effect is easy to predict. The users waste their time to tell these tools, how to perform any single task, and moreover - they do it many times. The risk of making a mistake is very significant then. Basing on our own experience and observations, we noticed that most of the problems that the template writer may find (list generation etc.), can be reduced to a simple combination of a few elementary operations. We decided to write a set of such operations and teach the template engine, how they can work together. Thanks to it, as a template designer you may focus on WHAT you want to make, not - HOW it must work. Open Power Template can decide what is the best way to connect the elements in order to simplify your life and save you from repeating yourself. Of course, some effects still require your assistance, but we are doing our best to eliminate such situations.

The new Open Power Template contains a built-in XML parser that fully understands the structure of your HTML code. It can find unclosed tags and perform complex operations on its structure. The performance is also the key. Every template is compiled into the PHP code, so that its execution is fast and can be speeded with the PHP accelerators. What is more - the compilation is done only once and its result remembered for the further use.

Good design

Open Power Template has some key goals:

  1. The KISS rule - simple things must stay simple. Why should you teach the template engine, how to connect the data of two nested lists? This is obvious!
  2. The DRY rule - do not repeat yourself. Why should you teach the template engine, how to display a list of results every time you want to do something like that?
  3. There is always another way. Unsually there is more than one solution for the problems you may come across. Choose the tools as you wish.
  4. Template is a template, script is a script. Why should you rewrite your templates every time you do a little change to the engine? Just inform the compiler and it will do this job for you.

Good syntax

Open Power Template has a clean and easy to understand template syntax based on XML and typical programming languages. We do not reinvent the wheel. If the function is written as function(arguments) in every language you can imagine, we do not see any reason, why OPT should be different here. Moreover, the library encourages not to make use of programming structures on the template-side. The key is to understand the way, how the elementary operations can be combined.

Good API

Another important aspect of the library is a good programming interface which makes it usable. Even here we promote simplicity and performance. In order to use OPT, all you have to know are a few methods and the knowledge, how OPT produces the output from our data. Open Power Template is also able to perform some tasks not-so-strictly connected with the HTML generation.

Good documentation

Even the best project means nothing without a good documentation and user manual. Have you ever found a nice library that seemed to solve your problems and you had to abandon it due to the poor quality of help and documentation enclosed in a couple of wiki pages? Open Power Template is a well-documented project. The library is equipped with a huge user manual with many tutorials, examples, syntax descriptions and API reference. It is being designed together with the library and constantly improved to meet the readers' needs.