New template engine - retry

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi guys!

Some of you may remember an earlier post about a smarty-esque PHP
template engine that I made. We sortof got stuck on the name, cause I
didn't know any so had called it a horrible name ("Farty"). Thanks for
all your suggestions on that matter, though, but after some busy
months I ended up picking a different name, and doing some bug fixes
and improvements.

As such, ladies and gentlements, I present to you

"mplate, a PHP template engine that Doesn't Suck(tm)" (or at least,
that's what I hope)


Now, naturally I'm convinced that there is a "market" for a thing like
this, otherwise I wouldn't have published it, but I'd really like to
know what you guys think. As such, if some of you have some time to
spare, would you mind checking out the site, the code too maybe, and
tell me what you think (here or as a comment on the site)?

Additionally, does anyone know how to go about marketing an open
source PHP library to the world? The only real interest I have in many
users is feedback and patches, and of course the fun of being involved
in a library that actually helps people; but I'm convinced that this
is an improvement over Smarty (and the other, newer, template engines
that I could find) in many ways and despite the age of Smarty it is
still very widely used. How do I convince others without becoming a
drag? How do I poke the people who care and not annoy those who don't
give a shit? :-)

Any feedback, comments, ideas is most appreciated, both negative and


Egbert Teeselink

Re: New template engine - retry

Egbert Teeselink wrote:
Quoted text here. Click to load it

Here is a marketing tip: tell me why you think this template is better
than other template systems. Tell me why you think it is better than
Smarty. Actually, I don't use Smarty, so tell me why it is better than
the template system offered in the Symfony framework. Or, for that
matter, any other framework.

Re: New template engine - retry

Quoted text here. Click to load it

Sure thing.

There are two central points where I believe mplate is different from
other (modern) PHP template engines. First of all, mplate is very
simple and still completely flexible: this is because any PHP
expression is a valid mplate expression (compare to smarty modifier
syntax, which often breaks the moment you want to do something
complex, inviting for ugly hacks and workarounds). Yet, you still have
the advantage of clear, clean code that looks pretty when plainly
viewed in browsers, is easily maintained and can be quickly understood
by non-PHP-programming designers. Similarly, the standard looping
constructs, such as foreach, have the same syntax as in PHP (compare
to smarty); Why force developers to learn yet a new language if the
one PHP offers is fine?

Secondly, mplate is designed to be very easily extendible. The API for
creating plugins, custom functions and whole classes is much simpler
than in Smarty (and other engines I had a quick look at), especially
when making so-called "Compiler functions" (which generate PHP code
instead of getting called each time the template is invoked). The idea
of all this is that *if* mplate gets a decent user base at all, well-
packaged plugins can be created, maintained and distributed
independently of mplate, and they will automatically work straight
after they get dropped in the right directory; without any speed

Many frameworks offer "Helper" objects or classes, but to me the
advantage of using those vanishes quickly if writing a helper method
call is more complicated than simply writing the tag it produces (it
certainly makes the code more difficult to read by other people, esp.
designers). An engine like mplate can be used to very easily (and
without speed penalties) provide a more friendly, more HTML-esque
syntax, with named arguments, for these helper functions.
Alternatively, people may develop plugin tag libraries that can do
typical "helper" jobs (like building form controls) independently of
the framework used.

Per comparison, Smarty has a plugin wiki with long batches of code,
each following their own ideas, semantics and markup, many slightly
overlapping in functionality and definitely none working nicely

I believe these points are good enough to beat Smarty in nearly any
situation. Smarty's "disallow PHP" option was traded for flexibility,
so if you need that (though I can't imagine what for), don't use

Comparing to Symfony's template system is a different case altogether;
I had a quick look, and it seems that Symfony does not at all have a
template engine; its views are plain PHP files. This is perfectly
fine, and the choice of whether to use a template engine (which is
essentially nothing but a preprocessor offering some syntactical
sugar) at all depends very much on the situation, and maybe even more
on taste. After all, PHP is a template system by itself. One with a
horrible syntax if you ask me, but many beg to differ.



Site Timeline