Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

The Logic of Templates (massassi.com)
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Article Discussions
View previous topic :: View next topic  
Author Message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun Jul 20, 2003 8:21 pm    Post subject: Reply with quote

While reading Michael Radwin's slide presentation, I discovered this interesting link which I think is relevant to this topic. In particular, the discussion on the Dataset Driven Template shows an insightful model to which Smarty can be readily applied.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Aug 08, 2003 4:12 pm    Post subject: Reply with quote

There is an interesting dissection of several templating techniques here.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Aug 28, 2003 8:11 pm    Post subject: Reply with quote

Is anyone familiar with the recent Savant project that has been making the rounds recently? It looks like the pure PHPer's response to Smarty. At least, it makes a lot of allusions to Smarty (starting with the name) and supports the same basic work/data flow patterns. No caching or security, as far as I could tell. Of course, none of the syntax niceties that Smarty provides.

Mostly, I'm curious as to why so much energy developer energy is being devoted to systems like Savant. Are people that allergic to Smarty's simplified syntax?
Back to top
View user's profile Send private message
jc
Smarty n00b


Joined: 13 Jul 2003
Posts: 2

PostPosted: Fri Aug 29, 2003 7:02 pm    Post subject: Reply with quote

probably. i tried smarty ages and ages ago and was impressed by its power. i also at the same time wanted to "do it myself". just for the satisfaction. and if you can live without the tons of library stuff that smarty provides and can make do with a slightly harder syntax then a lot of satisfaction can be derived from DIY. i made a template engine with caching and compile-to-php with a nice simple syntax and i was quite pleased with myself and have no real need for smarty atm. but i havent got a smarty allergy :p
Back to top
View user's profile Send private message
zteken
Smarty n00b


Joined: 12 Sep 2003
Posts: 1
Location: Systemadministrator, programmer

PostPosted: Fri Sep 12, 2003 5:15 pm    Post subject: Reply with quote

Brian I love your template engine. I use the new and improved one and life couldn't be simpler. I found a litte bug though in the new one. The extract function-call in fetch() expects the first argument to be an array, well if it isn't a PHP-errormessage is printed. To fix it I just added this:
Code:
if (is_array($this->vars))
extract($this->vars);

_________________
Stefan Sager
Back to top
View user's profile Send private message Visit poster's website
BRDude
Smarty Rookie


Joined: 23 Nov 2003
Posts: 17

PostPosted: Wed Jun 09, 2004 11:26 am    Post subject: Reply with quote

boots wrote:
Is anyone familiar with the recent Savant project that has been making the rounds recently? It looks like the pure PHPer's response to Smarty. At least, it makes a lot of allusions to Smarty (starting with the name) and supports the same basic work/data flow patterns.

I think its unfortunate that Savant chose to present itself as an alternative to Smarty, I still regard it as a powerful solution though.

I have no Smarty allergy, I just think Savant's appeal is in its simplicity. Caching is not a requirement since nothing is compiled or precompiled (only PHP itself), and the author seems to like the idea of allowing the developer to use his own favorite caching solution, specially when it's wise to use the same caching solution across the whole application.

Security is an issue with Savant, that's why it can only be used where template developers are trustworthy. Since in most of my projects I'm the one making the templates, I guess I can trust myself not to secretly hack my own application Smile
Back to top
View user's profile Send private message
onox
Smarty n00b


Joined: 06 Oct 2004
Posts: 2

PostPosted: Wed Oct 06, 2004 7:59 pm    Post subject: Reply with quote

the solution: static html pages! yeah, no more fights about wrong syntax / PHP code Very Happy ...

Arrow Smarty is still the best greatest coolest template engine because it contains so many fantastic cool features Smile and (in my opinion) has a simple syntax (no ugly PHP tags). bah! it is so slow and so large. hmmm.... i would like to see it being recoded, using php5 (great OO, exceptions) and make it much smaller -> and I will call it the ultimate best greatest coolest template engine then Cool

It's only the large size that prevents me from using Smarty.

Arrow however, I don't think there will be an ultimate Smarty in the near future, so if you don't like the big fat one, I would consider using a template engine that use native PHP. You could use HTML_Template_Xipe from the PEAR repository, which doesn't use his own syntax, but uses delimiters to avoid the use of ugly PHP tags.

hehe, maybe Xipe is the solution for the ones that don't want to use big fat Smarty.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Oct 06, 2004 9:26 pm    Post subject: Reply with quote

onox wrote:
Smarty is still the best greatest coolest template engine because it contains so many fantastic cool features Smile and (in my opinion) has a simple syntax (no ugly PHP tags). bah! it is so slow and so large. hmmm.... i would like to see it being recoded, using php5 (great OO, exceptions) and make it much smaller -> and I will call it the ultimate best greatest coolest template engine then Cool


Hi onox,

"so slow" and "so large"? How about some clarification on that? Smile

I just want to set the record straight: PHP5 does not have "great" OO -- it is simply better than the PHP4's effort. Still, I don't understand why there are hordes trying to start a stampede to adopt those features just for the sake of adopting them. I haven't seen one post or comment made in reference to PHP5's OO and Smarty that suggested HOW and WHY Smarty would be better using those features. I personally think that there is room for a new PHP5 template engine but as far as PHP4 goes, I think Smarty is the cat's meow Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Oct 06, 2004 9:54 pm    Post subject: Reply with quote

boots wrote:
"so slow" and "so large"? How about some clarification on that? Smile


Yeah I'd like to see some clarification as well. What is slow, and compared to what? Sure Smarty is bigger than your average template engine, but it also facilitates way more functionality too. Let's take the same argument to PHP directly:

[scarcasm]
Hey, PHP is a big bloaty mess of code aching from backward compatible aliases and strangely named functions! PHP is just compiled C code, why not write in C? That has to be faster!
[/scarcasm]

Well the problem with that philosopy is that PHP facilitates a huge amount of tools to make web development quick and painless. If all you want to do is submit a form and save the contents, there may be a more efficient way than PHP and its shear size, but even these simplest of tasks are just easier to do with PHP. As your application scales in size and features, PHP will supplant your needs easily. I feel that the same analogy can apply to Smarty and application presentation.
Back to top
View user's profile Send private message Visit poster's website
onox
Smarty n00b


Joined: 06 Oct 2004
Posts: 2

PostPosted: Fri Oct 08, 2004 10:11 pm    Post subject: Reply with quote

I must say that Smarty is indeed fast for its size and capabilities. However, compared to the rest of all template engines, it's slow. If I need a template engine that gives fast performance to handle a lot of page requests, I will not use Smarty imo. Am I wrong? In what kind of environment should Smarty be used? Enterprise? I think their websites need to handle requests very fast.

Btw: I can not find the benchmarks of Smarty and other template engines on bTemplate's website. Where can I get it?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Oct 08, 2004 11:17 pm    Post subject: Reply with quote

onox wrote:
I must say that Smarty is indeed fast for its size and capabilities. However, compared to the rest of all template engines, it's slow. If I need a template engine that gives fast performance to handle a lot of page requests, I will not use Smarty imo. Am I wrong? In what kind of environment should Smarty be used? Enterprise? I think their websites need to handle requests very fast.

Btw: I can not find the benchmarks of Smarty and other template engines on bTemplate's website. Where can I get it?


You got some real-world benchmarks to prove those statements?
Back to top
View user's profile Send private message
BloodRath
Smarty Rookie


Joined: 06 Jul 2003
Posts: 23
Location: France

PostPosted: Mon Oct 11, 2004 9:53 am    Post subject: Reply with quote

just to say that speed isn't always the first arg of choice
i have choose smarty not for speed but because it was very easy to extend.
_________________
froggies forever.... Wink


Last edited by BloodRath on Mon Oct 11, 2004 2:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Oct 11, 2004 1:43 pm    Post subject: Reply with quote

onox wrote:
However, compared to the rest of all template engines, it's slow.


That is an ignorant blanket statement. Smarty may not be the best solution for an atypical "hello world" test, but it is very fast when rendering a page made up of a few template files and looped variables. Which is more common in your applications?
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Oct 11, 2004 3:26 pm    Post subject: Reply with quote

Actually we're getting a bit off topic here, so I'd like to focus a comment that is on-topic. The massassi article makes a comment about Smarty that I'd like to clarify a bit:

Quote:
While Smarty gets it right in that sense (it allows you to harness pretty much every aspect of PHP), there are still some problems. Basically, it just provides an interface to PHP with new syntax. When stated like that, it seems sort of silly. Is it actually more simple to write {foreach --args} than <? foreach --args ?>? If you do think it's simpler, consider this. Is it so much simpler that there is value in including a huge template library to get that separation? Granted, Smarty offers many other great features (caching, for instance), but it seems like the same benefits could be gained without the huge overhead of including the Smarty class libraries.

[...snip...]

While I think this method is far superior, there are of course some issues. The first argument against such a system (well, the first argument I would expect) is that PHP code is too complex, and that designers shouldn't be bothered with learning PHP. In fact, PHP code is just as simple (if not more so) as the syntax of the more advanced template engines (such as Smarty). Also, you can use PHP short-hand like this: <?=$var;?>. Honestly, is that any more complex than {$var}? Sure, it's a few characters shorter, but if you can get used to it, you get all the power of PHP without all the overhead of parsing a template file.



This is whole argument is a bit misleading. Yes, Smarty has its own template syntax, but not for the sole purpose of making the syntax simpler than straight PHP code. Smarty has it's own syntax mainly for the purpose of insulating the template designer from PHP. The templates should be dealing with presentation, nothing else. Handing over the full firepower of PHP in the templates can certainly have its consequences, this is kind of like handing someone a swiss army knife even though all they require is a spoon. The template syntax was designed with the template designer in mind, giving them an easy-to-use subset of the power of PHP without direct access to all of PHP and its own syntax obscurities.

So the next thought is that this extra layer is going to cause a performance hit, but not as much as you might think. Remember that Smarty compiles the template files into PHP code, so {$var} becomes <?php echo $smarty->_tpl_vars['var']; ?> inside the compiled template, much like it would be if your templates were straight PHP in the first place. The compiled template is used thereafter, the original file is no longer parsed. The only notable overhead you are going to incurr is loading the Smarty library itself, which is pretty inconsequential with a PHP accelerator, and with the wealth of tools Smarty brings to the table should certainly make it more inconsequential... Smarty includes a lot of boiler plate tools that you would need to build into your presentation logic anyways.
Back to top
View user's profile Send private message Visit poster's website
Rikaelus
Smarty Rookie


Joined: 25 Feb 2005
Posts: 14

PostPosted: Fri Jun 08, 2007 5:48 am    Post subject: Reply with quote

The beaten horse has been revived!

Coming out of an IRC discussion about templating, and Smarty in particular, I googled the topic, found the article this was based on, and found my way to this somewhat-ancient thread. But dated or not, I think it addresses the arguments very well.

I agree with pretty much everything boots' has said, and his responses to the arguments were much better spoken than my own. Thanks for that, boots. I'll probably reference this thread should I befall another similar discussion.

I did want to re-emphasize mohrt's final point about Smarty syntax being an insulator so that templates don't include PHP code directly. I suppose one could see value in that for the same reasons that people appreciate PHP functions that auto-generate HTML; it insulates you from explicit code and syntax you don't want to see in the current development environment.

That said, perhaps one of the greatest aspects of Smarty is that simple piece right there. It might also become a point of contention because it has little to do with processing, and more to do with how it appears to the human eye. Indeed many seem to have taken on that argument, only to be, in my opinion, debunked with ease by the fact that templates are compiled; allowing the benefit of human-readable templates and easily processed PHP. Add to that the fact that plugins are included and loaded only on-demand and the whole system doesn't strike me as having a lot of overhead.

On that note, now that some time has passed, does anyone have any good benchmarks? Fetches for conventional pages in my system average around .04 seconds render time, without caching. I'm not sure how much quicker it could get than that!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Article Discussions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 5 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP