Apr 14 at 9:33am, Chris de Vidal wrote: > pete M said: > > Moving our sites to smarty is the best thing we've done at our company. > > Just a few weeks ago, I'd have agreed wit' yah, but now I see Smarty as > mostly (not always) redundant. see my post where I learned that PHP > makes a great templating engine: > http://marc.theaimsgroup.com/?l=php-general&m=108145205519710&w=2
If you just look at the basic operation of Smarty, by definition it's just a way to do exactly what everyone claims makes PHP a "templating engine". You could just as easily use Smarty to render a template once, copy the resulting cached .php file within your codebase, delete Smarty, and include the .php file in lieu of rendering the template with Smarty. And? If that's enough for the project at hand, then I am willing to bet Smarty wasn't being put to significant use anyway, and it's 50/50. I don't think that every piece of PHP code that builds page output should be done with Smarty. If you think it's redundant, please, avoid it like the plague!! I still see this point as being insignificant. Worth noting, sure, but not any major revelation. Being merely a tool, Smarty enables you to accomplish much more, with much less effort. Plain and simple. I don't recall anyone ever advancing the notion that Smarty turned PHP into something more than it was before. By definition it is merely a layer that makes your life as a developer easier. A tool! The amount of benefit derrived from a templating engine is proportional to how complex your templating needs are. Please note! I'm not suggesting that there is anything wrong with basic templates. As with any tool, the cost/benefit of Smarty must be weighed against the situation at hand. However, those of us who are seeing great benefit from the use of Smarty are not mere ignoramouses, and I feel that the implication being made is that we're not seeing what PHP can already do. This is false. Speaking for myself at least, Smarty was never a crutch. I deliberately sought out a templating solution to move beyond limitations I was bumping up against using straight PHP in the way that is being described. Nothing I have seen so far has addressed a single one of these issues adequately. Semantically, I take issue with the description of PHP as a templating engine, in the same way Smarty is referred to as a templating engine. This is because Smarty is, in most senses, a superset (or wrapper) built on top of PHP that offers many template-centric features that out of the box PHP does not. You can make a template in PHP. This does not exactly put it in the category of an "engine" anymore than it could be considered a form engine, a database engine, or an all-purpose engine engine. The reason this is such a contentious issue, I think, is because the point being made--while correct, and note-worthy--is short-changing Smarty by calling it redundant. I feel that one's use of Smarty may indeed be redundant, that's easy to do. However, Smarty is not inherently redundant. Using Smarty redundantly does not make Smarty itself one bit redundant. To make that claim, you're dropping a pretty heavy dis on a lot of people who have invested a great deal of time, effort, and subsequently realized great benefits from Smarty and it's templating brethren. Not to mention all those who have devoted great effort in the development of these tools. I'm seriously not trying to sound harsh here, but do you think that by realizing you could structure your PHP code in such a way to mimic a basic Smarty template, you've now single-handedly debunked the purpose for all of this effort by so many avid PHP programmers? Seriously, now...! No one should be under the illusion that you can't do it all with only PHP. Smarty doesn't do anything you couldn't do yourself in PHP, it can't! That is irrelevant, because Smarty is a tool. You need the tool, or you don't. That doesn't mean you always need it, but it certainly doesn't mean that serves no purpose or can't be utilized to save a lot of work. Many tools, if used properly, can save so much work that they enable you to do things that you would never feasibly accomplish by working in tiny pieces. This is why tools are developed. I feel like this exemplifies the issue at hand. Even if you can code PHP all day long without fatigue, and you are the most brilliant PHP coder the world has known, you'll basically end up having written something similar to Smarty. Why?! Because you can? So if we're trying to say that you don't need Smarty to make a simplistic template, I think even the most diehard Smarty fanatic will agree. It just sounds a lot like people who don't really see the power of Smarty, saying that it's got no power and no benefit. That is highly debatable, and I'm not convinced that many of these people truly grasp Smarty (even if they have used it, or claim to like it for some purposes). Unfortunately the end result is either you see it, or you don't. I would really love to post some magical, succinct example that would prove my point. If I could do that, I'd move right on to elucidating the ultimate OO example to put that issue to rest too. The point is, if you only work with designs that simple, don't bother. These approaches were not designed to solve those problems. So the fact that those problems can be easily solved with an alternative method really does not move the discussion forward a bit. I'm all for a discussion about these issues, were the topic "How can I do it without Smarty?" but to chime in everytime someone tries to advocate a valid, useful tool.. Aside from being slightly off-topic, and raising the dander of people who are harnessing the power of those tools, my main concern is that this may deter some less-experienced coders away from something that could potentially take their work to new levels. Regardless of the merit of the point being made, I don't think that benefits anyone much. I'm sure when some guy came up with a metal knife, there was a dude there with a sharp rock saying, "but this works too!" Then the guy with the knife started using it to cut everything, while the rock required constant honing to remain sharp enough to do half the work. But the guy with the rock thought it was all he needed! I use a knife. -- Kelly Hallman -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php