Some excellent points, however Smarty makes it much easier to do certain tasks than doing it in strait PHP and Smarty is extendable with PHP both directly and indirectly, you can create Smarty modifiers and functions and if necessary write inline PHP code.
Web development has an hourly cost even when quoted per project, if I can shave 2 hours of time off of a project I've saved the client $100 to $150 on budget or increased my profit margin depending on the project and the client. Those two hours are also time that can be invested in polishing the project or documenation, increasing the liklihood of an additional contract with them. Smarty is also open source so you aren't locked into a particular language, if you don't like it you can change it or extend it easily. You can change quite a bit of its behavior including opening and closing delimiters, etc. html_options is an excellent example of smarty functionality eliminating several lines of code and several minutes of coding, sure you could duplicate or implement the functionality in PHP but why re-invent the wheel. Smarty also has the benefit of introducing template caching and some other really powerful features that arne't available natively in PHP, you could use some PEAR classes or other functionality or implement it yourself but then you get into the whole re-inventing trap again. In many ways Smarty helps turn PHP into an even faster rapid application development platform for me resulting in more profit and a much more stable platform to use for clients, resulting in fewer complaints and a lower defect rate. I think this conversation has resulted in quite a few good points on both sides but has also exposed that most people already have a bias towards one technique and are unlikely to be swayed to the other side until a business need arises that forces it. Jason A really good example woul -----Original Message----- From: Justin French [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 07, 2004 9:02 PM To: Kelly Hallman Cc: [EMAIL PROTECTED] Subject: Re: [PHP] smarty On 08/04/2004, at 11:35 AM, Kelly Hallman wrote: > Apr 8 at 10:26am, Justin French wrote: >> PHP itself is a great templating language :) <h1><?=$title?></h1> >> <table> <? foreach($staff as $person): ?><tr> >> <td><?=$person['firstname']?> <?=$person['surname']?></td> >> <td><?=$person['role']?></td> <td><?=$person['phone']?></td> <td><a >> href='mailto:<?=$person['email']?>'><?=$person['email']?></td> >> </tr><? endforeach; ?></table> > > Uhhh, yeah--that's not a templating, that's called spaghetti code :) I fail to see the difference in complexity. Taking an example straight form the smarty docs: <table> {section name=mysec loop=$users} {strip} <tr bgcolor="{cycle values="#aaaaaa,#bbbbbb"}"> <td>{$users[mysec].name}</td> <td>{$users[mysec].phone}</td> </tr> {/strip} {/section} </table> Looks the same to me as: <table> <? foreach($users as $user): ?> <tr bgcolor="<?cyle('#eeeeee','#dddddd');"> <td><?=$user['name']?></td> <td><?=$user['phone']?></td> </tr> <? endforeach; ?> </table> (yes, I wrote a cycle() function in about 30 seconds) > I guarantee another person not as adept at PHP will screw that code > up, and there is less potential for that with a Smarty template. If > you know PHP as well as yourself, it should be plain to see how Smarty > is just a wrapper over PHP that makes templates easier to build and > maintain. > For a designer or non-coder, Smarty will be easier to learn than PHP. Not in my experience. Smarty lies somewhere in between a programming language and pseudo tags... In *my* experience training template designers... {section name=mysec loop=$users} was more confusing than: <?foreach($users as $user): ?> Your mileage may vary, of course, but that's not my point. > Unless your needs never exceed the very basics like you have > demonstrated above, you'll be hosed when another person needs to > modify your template. > Which goes back to a templating truism never in dispute: if this is > all you want templating for, it's six of one, half a dozen of the other. > > However, there are practical limitations on what you can easily > accomplish with this approach, and Smarty addresses those issues. And > you're worse off if you invest a lot into building your sites this > way, and then realize you need some better templating strategies > later. WHAT??? Are you suggesting that smarty templates are MORE EXTENSIBLE than straight PHP??? This is exactly my point. If you run with Smarty, you're LOCKED IN to that language virtually forever. Anything Smarty can do, I can replicate with PHP (obviously), plus a whole heap more. Smarty adds a layer of limitations and simplicity to your templates, but at huge cost: You're locked into a proprietary templating language. When that language fails to deliver everything you want/need, you have no where to go. A agree Smarty is fantastic at imposing limitations on it's templates, but this is it's strength AND it's weakness. > You can consider it it's own language, but really it's more like PHP > with different formatting. Which is why it's different than what > you're doing above--it's designed to facilitate templating. Your > method is just poking in variables and PHP into inline'd HTML. It > works, but you're missing some of the power of Smarty if you think > that's all it's good for. I agree, there's more to smarty, but in the end, it's just an interface to PHP -- eventually you will hit the wall with the functionality that the interface allows. Pure PHP templates however will only ever be limited by PHP itself. > In other words: are your template designers already good PHP > programmers? > It's not just hype, it solves real problems, even if you don't have > them. As stated, this was not a problem for me, but it IS a problem for some. Smarty is not a solution to every world problem. It has it's place for sure, but I felt the need to point out that PHP alone is a great templating language, with limitless functionality. It's up to the OP to take this thread and decide what he/she will do next. --- Justin French http://indent.com.au -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php