Let's play with eZ Components : Template and SystemInformation

One of the main topics at the eZ Conference was the eZ Components. In fact, it's quite logic, eZ Components will be the base of the future eZ Publish. As announced in the last community newsletter (page put offline since...) migration to eZ Components in eZ Publish will be made step by step and the version 4.0 of eZ Publish will include the Template component, so it's time to have a look at it. I had already tested the Graph component and the PersistentObject one too. I was very impressed by the quality of those libraries even if I had some weird system related problems with PHP PDO.

I built a very simple application that uses the Template component to display informations provided by the SystemInformation one. I notice some improvements in this new template engine :

  • it seems more strict. it's a good news for developers. In my opinion, strictness is mandatory to have a predictive and easy to use templating system.
  • there are many new operators and the syntax is more consistent.
  • the syntax of templates is a bit different but there are some improvements that make developer tasks easier :
    • a template has to declare variables that it will use with the use keywords so you can see what you can use in templates. Templates can also send data to templating engine ;
    • local variables have to be declared at the top level scope, no more declaration in the middle of a loop ;
    • I love the 1..10 syntax to build an array from 1 to 10 ;
    • there's no more wash operator, everything is automatic with the context of the template engine and if you don't need it, you can use [the raw keywords.

For me the new template system goes to the right direction, it's more strict and by the way easier to use, operators seem more consistent and the new syntax brings some facilities that simplify developer's life. We now have to wait until the end of 2007 to use it in eZ Publish...