On Mon, May 10, 2010 at 11:37:21PM -0400, Robert Cummings wrote: > Paul M Foster wrote: <snip> >> >> Lots of people use templating systems and particularly Smarty. Here's >> the difference between a templating system and just hand-coding: >> >> Hand coding-- >> >> <input type="text" name="flavor" size="20" value="<?php echo $flavor; >> ?>"/> >> >> Templating system: >> >> <input type="text" name="flavor" size="20" value={flavor}/> >> >> (Okay, I'm not familiar with Smarty syntax, but in essence template >> systems allow you to type less when you want PHP values to show up on >> the page.) >> >> Advantage: It *may* be easier for non-programmers to "read" the page >> with templating systems. I'm not sure this is really true. They're still >> liable to say, "What the heck is {flavor}?" Besides, my inclination is >> to tell designers to make everything look pretty, turn the resulting >> HTML over the the coders, who will then mark it up for PHP. After that, >> the designers can stay away from it. >> >> Disadvantage: You're adding another layer (and a LOT of code) just to >> save yourself some typing. With straight PHP, the server reads the code, >> interprets the PHP, substitutes values and shoves the page down to the >> browser. With a templating system, the system must load and call the >> templating engine, which must then substitute the proper values, and >> then output the built page to the browser. >> >> Your choice. > > I get tired of correcting this incorrect assertion. Some templates > engines do what you describe. Not all. Some directly generate PHP source > code which is then either directly accessed via the web server or > directly included by another page. Generating PHP code from a template > engine can provide superior benefits over pure PHP since the distilling > of simple XML (or otherwise) tags can be rendered once via simple or > complex PHP processing during template compilation versus the same > processing being done on every page request. In fact some will produce > plain HTML that doesn't even require the PHP interpreter. Okay, you're clearly more familiar with templating systems than I am. My impression of templating systems is that the templating engine scans the raw page, makes substitutions, and then outputs the page to the browser, all on the fly. You're saying this isn't always the case. Are you saying that some templating systems simply generate output, which may then at some later time, be requested by the browser? That is, they would function somewhat like a combination of "make" and "m4" (a macro processor)? So a programmer would code his page, then call the templating engine, which would output the final page to disk, so it is now available for download? Is that the distinction you're making? Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php