RE: Smarty and speed

From: Date: Sun, 09 Dec 2001 22:48:41 +0000
Subject: RE: Smarty and speed
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2227@lists.php.net to get a copy of this message
Hey Peter, Thanks for the nice reply. I am still here... The issue with my rant is that the original post I placed on the list seems to have turned into a "Pablo doesn't have experience, so he can't understand..." type of thing. I even get responses saying, "If you don't understand why templating is so important then you just don't get it". That's a little frustrating. None-the-less, I apologized for my rant. But I think I should be clear on a couple of things. I have been using PHP since it was a joke. I program daily in PHP and have programmed in many other languages. I have used FastTempaltes and PHPLIB templates EXTENSIVELY. I am not new to templating. I have used Smarty as the basis for my project at www.phpshop.org and have the potential to make it the standard for our user base of several thousand. In working with Smarty (we have it fully integrated with phpShop) I realized that since we approach our development using the MVC framework (model-view-controller), Smarty was not really giving us the type of abstraction we needed from the business logic in an effective way for designers. That is, Smarty was doing nothing more beneficial for us than replacing PHP. Sure, it offers caching and some other cool things, but realistically, it was not keeping our designers away from having to code the display logic. The reality is that there is probably no way to separate the two. So, in an effort to understand if Smarty was more in-line with our future plans, I posted a general list of questions asking for the "arguments for Smarty". What I received was not giving me the warm-fuzzies I was looking for. In reality, using PHP/HTML to "output" of your pages is just like using Smarty. All you need to do is be 'smarty' about how you code. For example, <?php $my_array = array("var_1" => "Home Page", "var_2" => "Welcome to my home page"); include("mytemplate.php"); ?> Inside mytemplate.php: <? include("header.tpl");?> <H1><? echo $my_array["var_1"]; ?></H1> <? echo $my_array["var_2"] ?> <? include("footer.php") ?> As you can see, it looks almost like Smarty templates do. And if you want caching, why not use Last-Modified and If-Modified-Since headers as defined in HTTP/1.1? That can be done quite easily. Anyhow, to make a long story short, we are moving the project to XSL. We will still leave Smarty as a plug-in those who want to use it. We will also offer PHP/HTML as we do now. But, when it comes to our 'recommendations', we will be promoting XSL all the way. Sure, XSL still requires designers to code logic in their XPATH statements. But, I'd rather go XML than simply replace PHP with Smarty for display purposes. It just doesn't make sense. Plus, XSL allows you to go from XML to XML/HTML/WAP/whatever... Yeah, I know... Smarty does too... But in that case I'd simply use PHP. Pablo -----Original Message----- From: Peter Bowyer [mailto:reywob@f2s.com] Sent: Sunday, December 09, 2001 5:08 PM To: Pablo; smarty@lists.ispi.net Subject: Re: [smarty] RE: Smarty and speed At 04:22 PM 12/9/01 -0500, Pablo wrote: >I apologize for being nasty. I just hate being treated like "I don't get it". Brent didn't deserve your rant Pablo. Your two opposing views are a question of relativity... from Brent's point of view as a *proper* (as opposed to PHP) programmer the Smarty template system really isn't like programming. From your point of view (and I am assuming that you do not have Brent's experience - my humble apologies if you do) Smarty seems like a programming language (I prefer to call it a macro language - it helps me to do my job much more easily). For a designer who understands javascript (as some do) then Smarty won't pose any problems. For those that are pure designers, it will. I know people find Smarty difficult if they are only used to HTML - I've come up against this problem. Just remember that these same people are going to have to grapple with XSLT within the next 5 years (something which is far more complicated, and IMNHO blurs the separation between logic and presentation even more). In the past I have asked myself the same questions as you have been asking on this list. I'm still not happy about mixing some logic with the display like Smarty does (I keep feeling there must be a 'perfect' solution, but I can't think of it!), but then I think that if this is what XSLT is going to do, there can't be much wrong with the idea :-) Use Smarty when it is useful. Use other tools when they suit the job better. I also worked with PHPLib templates for a long time, and I find Smarty to be much easier to use _because_ it mixes some logic in the code -the number of times an {if} statement in a PHPLib template would have simplified my code are too many to count (have you ever had to conditionally delete blocks from a template?) I suggest you think of Smarty as I do, and treat it as a macro language. On large, complicated projects it does save time. Thank you for reading so far, and goodnight :-) Peter. --oOo-- Narrow Gauge on the web - photos, directory and forums! http://www.narrow-gauge.co.uk --oOo-- Peter's web page - Scottish narrow gauge in 009 http://members.aol.com/reywob/ --oOo--

« previous php.smarty.general (#2227) next »