Alexa's Blog

Reliable $1 Web Hosting by 3iX

Reliable $1 Web Hosting by 3iX

SoMuch.com: Internet Links Directory



Php Programming-Free Ft template class

April 26th, 2007

Hi fellows,

Here is a class I wrote some years ago (2003). It´s a PHP template class which allow you to separate the html code from the php one.

Initially was published on the phpclasses.org website, it is still there but because is much easy for me to keep track and help users on my own blog, I decided to make it available here also. Many people have contacted me directly with different questions and this was another reason for which I add the template class here.

Php is one of the scripting languages I liked most and I wrote this class as a replacement for the FastTemplate which I was used for a while in my php projects. As in most of the cases, with one of the projects I noticed a big hit in the performance and because the template engine was the reason I have decided to write my own. The result was 10 times faster on the same data set and I have added support for nested dynamic blocks which didn´t worked well in the original FastTemplate class.

From that time, over 4 years have past and new engines have been created. I think the most used one is Smarty but is one of the engines I never liked.Don´t ask me why :) . So I still use this in all my company projects and in all those years was nothing I can´t do with my FT template class.More than that, the only changes added have been a function which allow you to assign a template from a variable(coming from database in most of the cases) and a small fix that solve some problems on PHP5.
If you need a light(400 lines) php template engine, fast and easy to play with, you are free to download it from the end of this post. If you have any questions, don´t hesitate to ask or express your opinions because I will enjoy by any feedback I get. Nobody asked for a tutorial yet, but if someone needs one, I will write one.

Get ft class and Enjoy!

4 Comments »

  1. zero says

    good.i look for a simple php template engine these days,i will download yours and make a test.

    Thanks a lot.

    June 12th, 2007 | #

  2. zero says

    i download it ,and view your sample and main class.i am glad to say it is so simple and easy to use.you did a good job.Thanks.But i am so sad to say no If-clause support in your engine.so i must find other one.

    June 12th, 2007 | #

  3. cornelalexa says

    Hi Zero and thanks for visiting.

    Personally I don´t think that a template engine should contain any programming logic at all and for that reason you will not fund any conditional logic support in ft.

    Since you have just started I suppose you are at the beginning with templating and my advise is to stay away from this method of doing things.

    PHP is very good as a language, so I don´t see any reason to embed into a template engine another language.
    If you will look a bit over the dynamic blocks you will see a lot of ways to deal with the conditional blocks.Just put a bit your mind at work :???:

    Hope to see you back here so we can talk more on this subject.

    Regards.

    June 12th, 2007 | #

  4. PHP Encoder says

    Was searching the web again for templating engines and came across your blog. Interesting… You should not use programming structures within template. Too right! As your Web designers would fail to edit templates created by PHP programmers! :)

    March 10th, 2008 | #

Leave a comment

:mrgreen: :neutral: :twisted: :shock: :smile: :???: :cool: :evil: :grin: :oops: :razz: :roll: :wink: :cry: :eek: :lol: :mad: :sad:

RSS feed for these comments. | TrackBack URI

Your Ad Here