Page 1 of 1
Using Templating Engine
Posted: Wed Oct 12, 2005 12:12 am
by Ree
How many of you use some kind of templating exngine when you are working alone? By saying alone, I mean you recieve graphic design (HTML) from your client (or do it yourself) and code the required. The question applies mainly to freelancers, I guess.
Posted: Wed Oct 12, 2005 6:53 am
by feyd
I would like to use a template engine all the time, however, I leave that decision to the client giving them the list of pros and cons.
Posted: Wed Oct 12, 2005 7:01 am
by Ree
Well, why exatly would you want to use it? Since you're working alone, you can write those presentation-related echo's/if's/loops inside the HTML files without worrying some designer won't understand them.
Posted: Wed Oct 12, 2005 7:25 am
by feyd
So I don't have to come back at some later point to write in a new design, wasting lots of my time and their money.
Posted: Wed Oct 12, 2005 11:39 am
by foobar
@feyd:
Do you program a custom template engine (in an earlier post you said that you ususally do custom code), or do you use an established template system, such as Smarty or other?
Posted: Wed Oct 12, 2005 11:45 am
by andre_c
i almost always use a template engine, not because of designers, but because i find that it's cleaner
right now, i'm using Smarty with some modifications
Posted: Wed Oct 12, 2005 1:03 pm
by feyd
all custom.. although each is largely similar to the previous one.. but some features and things change between each to suit the client..
Posted: Wed Oct 12, 2005 2:00 pm
by Ree
andre_c wrote:i almost always use a template engine, not because of designers, but because i find that it's cleaner
Well, in what way do you find it cleaner?
Actually when you're alone and you get a develop-and-forget client, I guess there's not much point in writing those custom tags and then do the replacing, as I mentioned, it's faster to write simple php snippets by hand.
Posted: Wed Oct 12, 2005 3:14 pm
by Buddha443556
In my own programming, I don't use a template engine such as Smarty. However, I have customers that run scripts that use Smarty so I know how to use it. I'm not really sure there's any savings in either method ... well except maybe performance. I still get called to install new layouts either way.

Posted: Wed Oct 12, 2005 5:30 pm
by andre_c
Ree wrote:Well, in what way do you find it cleaner?
i find the tags easier on the eyes than php:
instead of
also there's some useful functionality like {foreachelse} and {cycle}
that look cryptic when done using php, but look very straightforward in smarty
Code: Select all
<table>
{foreach from=$users item='u'}
<tr class='{cycle values='odd,even}'><td>{$u}</td></tr>
{foreachelse}
<tr><td> -- no users --</td></tr>
{/foreach}
</table>
plus i added some functionality that i call widgets:
Code: Select all
{widget type='box' label='Content'}
some content
{/widget}
so i find it clearer, but it may just be preference
... also develop-and-forget type of clients are VERY rare (at least in my experience)