Page 1 of 3

What do you use for templating?

Posted: Sun Jul 09, 2006 11:49 am
by alvinphp
For those that use templating did you build your own template class or use something like smarty?

Posted: Sun Jul 09, 2006 11:53 am
by Roja
I use Smarty, although for a brief period I used Template-Lite, and if the security protections from it get ported to Template-Lite, I'll switch back to it.

I've looked at other solutions, but Smarty and TL are full featured enough that I haven't yet "hacked around" a limitation they have, while they are also small enough, and well-maintained enough that it keeps me happy.

Posted: Sun Jul 09, 2006 12:24 pm
by Christopher
I tend to switch between PHP, str_replace and XSLT templates -- even on the same page -- because I use hierarchical templates/response. So I have a set of little classes that implement minimal functionality. The whole thing is under 5k.

Posted: Sun Jul 09, 2006 12:51 pm
by AKA Panama Jack
Smarty was too slow and bloated so I helped write an alternative that was compatible with Smarty Syntax. It has become a very popular replacement/alternative to Smarty. :) The link is in my signature. :D

Posted: Sun Jul 09, 2006 1:02 pm
by Chris Corbyn
I use PHP ;)

Posted: Sun Jul 09, 2006 1:21 pm
by MrPotatoes
my own custom templating sytem. i've gotta add some more better functionality to it but it's wicked fast and tiny.

too bad i'm having problems with something currently. <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> forum code. *ugh*

Jcart | watch your language please

Posted: Mon Jul 10, 2006 2:38 pm
by alex.barylski
I use PHP deriving mine from bTemplate...

Simple and fast...

Occasionally I'll use Smarty (now Template Lite)...

Posted: Mon Jul 10, 2006 2:57 pm
by MrPotatoes
Hockey wrote:I use PHP deriving mine from bTemplate...

Simple and fast...

Occasionally I'll use Smarty (now Template Lite)...
i took a few cues from that one. i looked it over and that'st he one that i wanted to play with over the others

Posted: Mon Jul 10, 2006 3:07 pm
by Gambler
<?= ?>

Posted: Mon Jul 10, 2006 3:33 pm
by feyd
Gambler wrote:<?= ?>
ack. That's all I need to say without going into a rant.

Anyways... I use whatever makes sense at the time and as the needs of the people involved require. Sounds wishy-washy, but it's the truth. I will use whatever they want/need me to. They are paying for it, so it's their choice.

Posted: Mon Jul 10, 2006 3:38 pm
by AKA Panama Jack
Gambler wrote:<?= ?>
That will not work on server that has short tags disabled and most new versions of PHP have short tags disabled by default.

You would have to use something like...

Code: Select all

<?php echo $variable; ?>
...instead of what you posted above.

Posted: Mon Jul 10, 2006 3:49 pm
by alvinphp
AKA Panama Jack wrote:
Gambler wrote:<?= ?>
That will not work on server that has short tags disabled and most new versions of PHP have short tags disabled by default.
I have yet to see a public hosting company disable <?= ?>. And that includes newer versions of PHP. If you did disable the short tag a lot of legacy PHP and scripts would crash.

After some research I decided to stick with native templating (using <?=?>). Thanks for all the input!

Posted: Mon Jul 10, 2006 4:02 pm
by Chris Corbyn
I have no issues with seeing the use of "echo" and "print" in templates. It's logical and more obvious than a lot of template systems. Personal preference, that's all.

IMO, PHP provides all the constructs and more than you need to manage templating. Doing it this way reduces memory, increases speed and lets PHP do what it does well. Adding another layer to do the templating may provide some features that you'd need to otherwise code but I don't feel that those benefits far enough outweigh the advantages of just using PHP.

OK so this is not a real template system but it's along the lines some of the follow but why is:

Code: Select all

<table>
    {foreach %something = x}
    <tr>
        <td>%x</td>
    </tr>
    {end-foreach}
</table>
Any better than:

Code: Select all

<table>
    <?php foreach ($this->something as $x) { ?>
    <tr>
        <td><?php echo $x ?></td>
    </tr>
    <?php } ?>
</table>
EDIT | Don't get me wrong, I used to use template systems and actually wrote a few that introduced some new concepts so I'm not bashing them, I just have come to see that PHP already does everything that these systems are doing... but faster.

Posted: Mon Jul 10, 2006 4:07 pm
by feyd
The only time I push hard away from using PHP is when maintainence comes into play. More often than not, the person doing the maintainence will not have the knowledge necessary to correctly write the php, so I'll suggest more template engine systems to the client.

Now, when I do my php level templating, there's no business logic involved. It's purely display logic only. Keeping them separated is the key to keeping it all more easy to maintain, I feel.

Posted: Mon Jul 10, 2006 4:30 pm
by RobertGonzalez
TemplateLite. I think it is better and faster than Smarty. I use to use the phpBB template class, but it was slowing my apps down quite a bit, so I switched. I have also toyed around Savant, but that is just a PHP derivative that ends up using PHP syntax (it supports caching and such, but still not as user friendly as TL).

I have, on ocassion in the past, used PHP as my templating engine as well. It is well built for it. Just a little difficult to maintain the presentation code for designers that do not understand the PHP logic involved in displaying presentation.

PS Short tags should never be relied upon to be enabled. Even if you have never encountered a host that disables them, it doesn't mean that PHP will continue to support them.