Please create an account to participate in the Slashdot moderation system


Forgot your password?
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. ×

Comment The Template View (Score 2, Interesting) 90

The notion of templating in PHP (or any web platform) is described by Martin Fowler in Patterns of Enterprise Application Architecture as the Template View.

Implementation of the Template View is examined in some detail at, which begins looking at "Why use templates" then examines different styles of templating, in terms of their markup and the API they provide to populate the template with data. The purpose is to lay this discussion to rest once and for all.

Where PHP's concerned, the real question is why has everyone (and their dog) written their own template engine? In an ad hoc survey we counted over 80 public domain template enignes "out there"

What's even more puzzling is why 90% of them all look the same with markup like;

{if $font="bold"} Hello World! {else} Hello World! {endif}

...and a pinhole API like;


My guess at the reason why is public here


As to what template engines in PHP are actually worth using, there are only two IMO;

The first is PHP itself - use some self discipline and keep the pages where code gets mixed with HTML to the most basic PHP syntax - just the flow control statements like if/else, while and foreach.

The second is any which can offer templating capabilities similar to Java's JSTL or ASP.NET. Which is where WACT comes in. Check the examples to get the idea.

Slashdot Top Deals

"Floggings will continue until morale improves." -- anonymous flyer being distributed at Exxon USA