What do you use for templating?
Moderator: General Moderators
What do you use for templating?
For those that use templating did you build your own template class or use something like smarty?
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.
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.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
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'm naughty, are you naughty?'>smurf</span> forum code. *ugh*
Jcart | watch your language please
too bad i'm having problems with something currently. <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> forum code. *ugh*
Jcart | watch your language please
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
ack. That's all I need to say without going into a rant.Gambler wrote:<?= ?>
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.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
That will not work on server that has short tags disabled and most new versions of PHP have short tags disabled by default.Gambler wrote:<?= ?>
You would have to use something like...
Code: Select all
<?php echo $variable; ?>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.AKA Panama Jack wrote:That will not work on server that has short tags disabled and most new versions of PHP have short tags disabled by default.Gambler wrote:<?= ?>
After some research I decided to stick with native templating (using <?=?>). Thanks for all the input!
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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:
Any better than:
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.
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>Code: Select all
<table>
<?php foreach ($this->something as $x) { ?>
<tr>
<td><?php echo $x ?></td>
</tr>
<?php } ?>
</table>- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.
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.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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.
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.