Changing template engines

I think I’m going to change the template engine used for the Winning Side Ministries website. Up until now I’ve been using a very simple engine I designed myself. It only does simple tag replacement and inclusion.

Why did I decide to roll my own in the first place? Simplicity. I didn’t need anything more powerful at first, and I didn’t want to spend a lot of time playing with a more complex template engine. More than anything I wanted to just get the website up and running. It’s so simple I could have very easily just coded it all as static html with PHP code splattered through it and it would have been sort of readable. I knew that wasn’t the right way to do it, though, so I cobbled together my own template system.

Now that I’m going back and trying to polish the site up and bring up my scalability/efficiency levels, I see the need for something more than my coded-in-10-minutes template class.

A quick google search led me directly to smarty. I’d heard of it before; my good friend from high school told me about it years ago. I see why he was so excited! It does everything I need, and it does it efficiently.

The big feature I was looking for was the ability to display arrays of data as repeated elements in the template. For instance:  if I have page hit data, I want to section off part of the template that would be repeated for each point of data. Apparently it’s a common feature (of course, this makes sense) because it’s mentioned right in the smarty crash course; smarty calls these repeated blocks “sections”.

It shouldn’t be difficult at all to make the transition. I even have some ajax functions that return html generated from templates, which will be easily taken care of by the fetch() function of smarty.

So here’s to a great template system that won’t take long to implement in my setup.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: