RSS 2.0
RSS 0.91
ATOM 0.3
October 29, 2008

The Zen of Templating

By: Sebastian Kurfürst

Musings about the new templating engine, explanations why we need it, the syntax in a nutshell, and best of all: autocompletion. Discover the Zen Way Of Templating!

(image found at

During the transition days, we have spent some time on discussing a new template engine for FLOW3 and TYPO3 v4.

I felt really motivated after this week, that's why I started out to implement the concept we discussed there, mainly to gain some experience.

Why another templating engine?

We've been looking at many templating engines, including PHPTal and Smarty, but for each of them, there were some things that did not really suit our needs (We've written down some facts about that in the FAQ on forge).

As the templating engine will be an integral part of FLOW3, and one part the developer deals a lot with, we sat down to think about how templating should really be.

It should be simple and powerful. Not limiting your possibilities, but enforcing clean templates. Use convention over configuration. Provide guides and help whereever possible. Be intuitive and easy to learn.

Already da Vinci said "Simplicity is the ultimate sophistication" - so our template language is very slim, but also very flexible.

Introducing BEER3

Don't be scared, that's just the working name of the templating engine (short for Best Engineered templateEngine Replacement) - any ideas concerning the name are welcome!

Some terminology

View Helpers are just methods which you can use in your view, and they can perform various things. BEER3 ships with some standard view helpers (conditions, loops, link helpers, ...) but you can easily write your own.

Every view helper resides in a certain package.

Learning by example

Let's take an easy example: Imagine you want to output a list of all blog postings in a template. The follwing snippet will do that:

<f3:loop each="{posts}" as="post">
  • "f3:" is the namespace prefix for the default view helpers. You can register your own namespace prefixes, thus writing your own view helpers is really easy to do!
  • "loop" is the name of the View Helper - implementing a "foreach" loop. It takes two arguments, the object/array which should be iterated over and the name of the iteration variable.
  • Every time an object or array has to be passed to your view helper as argument, you use the "{...}" syntax. This is used in the "each"-Argument.
  • The "loop" view helper registers the iteration variable (in this example it is called "post"), thus it can be used inside the loop.
  • We want to output the post title here, thus we write {post.title}. The system checks if there is a getTitle() method on the "post"-object, or if there is a "title"-property which is public on the post object.

View helpers are very easily written. For an example, check our work-in-progress documentation in the wiki.


Quite soon after we started playing around with the template engine, I spent some time investigating autocompletion of the view helper tags.

And as an image is worth a thousand words, and a video is worth a thousand pictures, I have created a small mockup where I show how autocompletion can work in eclipse. Watch it here, as it is really cool!

As far as I know it, there is no other templating engine which allows you to do this right out of the box! Java Taglibs provide autocompletion, but you need to write a lot of XML for that... In our approach, all the definitions for autocompletion are automatically generated.

That's a feature which really thrills me, as this will make learning the template engine a breeze if you have a XML editor which uses XML Schema information (such as eclipse).

What about Zen?

We want to create a simple, extensible, robust and flexible template engine, which has everything you might need, but nothing more as well! Besides, we want to give you all the tools to make working with it as easy as possible (Autocompletion, wizards, ...).

So, to me, it's "templating how it should be" - all the things you need, but nothing more. Something of beauty and ease. Fun to use.

Current discussions

We are currently discussing details of the template engine on the mailing lists, so please join if you have some ideas ready!

Besides, I think now it is the right time to build up a small team around it. So, if you want to join, just contact me or write on the mailing lists!

Future plans

As I had a lot of positive feedback so far, both from v4 and v5 developers, my plan is to first build the templating engine for v5, and afterwards, backport it to TYPO3 v4 as well. If all goes well, we might have a really cool templating solution in TYPO3 4.4! But I need your help for that :-)

Greets from Dresden, Germany,


comment #1
Gravatar: sas171 sas171 October 30, 2008 00:16
I think its a very nice solution, nothing to add.

I would suggest to review one more engine Besides the features explained on the home page I can say, that the source code of the engine itself is pretty clean so maybe it will be a source for architectural ideas.

comment #2
Gravatar: Dmitry Dulepov Dmitry Dulepov October 30, 2008 10:23
I am still not convinced that it is better than Smarty. Smarty 3 is being developed now and they have a lot of experience and large community. You could just join forces with them, influence the development and save precious time for other work. Instead TYPO3 reinvents the wheel again and again :( I understand it is exciting and everything. But I do not think the choice is the most effective one.

comment #3
Gravatar: Sven Teuber Sven Teuber October 30, 2008 12:15
For god's sake, get rid of BEER3, it's ridiculous. Why not BETR3, it't the correct acronym, and if you pronounce it, it sounds like "better" (what it will be won't it? ;).

comment #4
Gravatar: Oliver Klee Oliver Klee October 30, 2008 16:03
What about a feature to htmlspecialchar the data that is being output?

comment #5
Gravatar: Kraig Kraig October 31, 2008 10:51
Good luck in creating your flexible template engine!
More Engines = More Competition = More Choice! :-)

comment #6
Gravatar: Stefano Cecere Stefano Cecere October 31, 2008 15:48
i have to admin to agree with Dimitri, and join Smarty 3 (so FLOW/TYPO3 5.0 would have a full working template engine from day 0, and many of us know it because it's used by several big opensource projects..

i just hope that it won't be the next never finished/supported project!

ps: i like BETR3 more that BEER3 !

comment #7
Gravatar: Robert Robert November 3, 2008 06:16
BETR3 is appealing, definitely, despite the tongue-in-cheek joke you'd have with BEER3.

comment #8
Gravatar: le hénaff, éric le hénaff, éric November 7, 2008 09:31
why a new template engine ?
there already are automaketemplate and templaVoila.

comment #9
Gravatar: Auyana Auyana November 12, 2008 17:07
We are using templaVoila - but if the new template engine shows to be more functional than we would use this one. When is it planned to be released? And how can programmers support you?

comment #10
Gravatar: George George November 14, 2008 22:03
Excelent comments, well done. Best regards

comment #11
Gravatar: thet thet November 18, 2008 02:50
cool template engine and good concept! i like it...

i don't use php not anymore but i want to point you to the zope/plone templating language: TAL (Template Attribute Language).

this document is a bit old but still valid.
i am really happy with tal and it rocks! (...when embedded in an MVC approach like zope3 style).

Sorry, comments are closed for this post.