Working of the template class

Okay… fistly, the grammar above is wrong :P . Well, this post is going to deal with how the template class actually works. The template class actually works in the following method:

  1. First of all, we take up the file of the template into a variable called contents. This variable is the property of the database, and is accessible through $this->contents
  2. Now, we filter these contents for various variables. I had initially started it up in an easier way. What the system did was, it used to take up the entire set of variables which were stored in the template’s “template_vars” array, and then repalce {$variable_name} in the template with the value of the variable.
  3. Then we move forward to filter the for and if loops in the template class. This is a tough task (believe me). This is as good as a parsing system in PHP. I have had fun doing this one.
  4. In the later stage of the template, I also added the inclusion of files into the template. This was real fun. But quite easy as compared to the other stuff.
  5. In the very end, we either echo the template or return the value as a string.

The development of PHP template class has been a challenge for me. In the later stages, I will also show you on the problems of most of the methods that I have given above. Most of them are bullshit ;) , but they are important as far as your systematic study of this system is concerned. I know I am on a tough road, as I am trying to teach you how to make a system that I am still trying to perfect, but rest assured, I am surely not going to teach you anything stupid. Whatever I write on this blog has some big meaning. I have studied these things over a period of 3 years. Here is your chance to take a short cut!!

About admin

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!