Preface

Open Power Template is a template engine written in PHP 5. While developing it we chose two main goals for it: to be fast, and to be flexible. We managed to do that. OPT uses a very effective template parsing algorithm, which compiles the templates into the PHP code. Of course they are stored on a HDD, so that we don't have to recompile them every time someone enters our website. When it comes to the flexibility, you may change here everything: from the instruction set and the syntax structure to... whole template engine. Yes! You may remove the original heart of the library and write your own, based on the OPT Compiler.

The feature issue also looks good. OPT provides both low and high level template syntax structures. Using programming instructions, like if or foreach you manage to do almost everything, whereas sections and components make your live easier. The full list contains:

  1. Fully flexible template syntax. You may set both your own tag delimiters and the way you are passing the parameters to instructions.
  2. XML-Syntax mode, where OPT uses XML-based tag delimiters instead of default. This allows your template to pass the W3C tests and also use it in WYSIWYG editors.
  3. Control structures, such as if, for, foreach, and expressions known from programming languages implemented.
  4. High-level structures that make the template writing easier. They don't require almost any knowledge of any programming language.
  5. Tree data rendering system.
  6. Components that improve form building etc.
  7. Support for compound types from PHP: arrays and objects. In the second ones calling methods allowed.
  8. High speed. There are implemented several optimizations, and you may speed up the template executing using such tools, as Zend Optimizer (this is because the templates are compiled into the PHP code).
  9. Built-in internationalization support.
  10. Object-oriented architecture.
  11. Custom template functions/instructions support.
  12. It is very easy to link the OPT configuration with your website one.
  13. HTTP header manager.
  14. GZip output compression.
  15. Output caching.
  16. Support for code filters.
  17. Support for custom resources (ie. templates are stored in the database).
  18. Built-in debug console.
  19. OPT API that allows you to build your own template engines based on the OPT Compiler.
  20. Additional tools: OPT Compiler (manual template compilator) and OPT Configurator (remove unused features from the library source code).

The library is available under GNU Lesser General Public License. You may use it and modify for free, even in commercial projects unless you remove copyright notes and do not earn money for just because of it.

Open Power Template is a part of bigger project: Open Power Board. Its goal is to create open-source and qood-quality discussion board. There are also another Open Power projects. Open Power Forms is the official add-on to OPT allowing to build really dynamic HTML forms connected with data validation and user info collecting. Open Power Driver is a layer for PHP Data Objects library with almost the same API, but extended with data caching feature. All the projects are developed mostly by Polish PHP community, but we do not forget about the rest.

Before we start, remember one thing... OPT is not a Smarty™ clone.