<ralphdahlgren.com>
<ralphdahlgren.com>
I'm sure that by the time some people read this article they will surely be thinking that I must have a strange fixation about template tutorials. Well, those people might be right. The fact of the matter is, Etomite is a template engine. Sure, the Etomite class has always been referred to as a parser, but it's much more than that. Some people have even suggested that Etomite should integrate a template engine such as Smarty or Tiny But Strong. Why? Etomite is a template engine. By using Etomite plus just the right amount of PHP you can accomplish virtually the same results, without learning yet another cryptic language. Etomite IS a template engine. Do you "get it" yet?
So, why yet another Etomite template tutorial? Well, because I have a fixation, for one. Aside from that, however, I feel that once people see the actual power that Etomite possesses they will begin seeing it as a real contender for developing web applications. Thinking of Etomite as merely a content management system doesn't begin to convey the potential that is present within the package.
On to the good stuff. This tutorial uses a snippet to abstract data from the database and displays the results in a table. Nothing exciting about that now is there? How it gets displayed is the crux of this tutorial. The fact that the snippet uses a chunk as a content markup template isn't all that new either - at least not to anyone who has read my other template tutorials anyway. Two concepts make this one stand apart from the rest, the use of the parseChunk() API function and the use of content tags based on PHP tags.
By using the parseChunk() API function we can effectively perform two template engine iterations. The first iteration is the replacement of content markup tags with parameters sent as a $key=>$value array in the parseChunk() function call. The second template engine iteration is performed by the embedded PHP loop within the chunk markup itself. For this particular chunk template I have chosen to use PHP open and close tags along with the tag name being a PHP remark, without any white space within the tag. There are two advantages to using this method. First, any tags which don't get replaced by parseChunk() will not be visible in the resulting markup. Secondly, a benefit created by the first, is that the absense of the unreplaced tags won't jeopardize HTML markup validation. Essentially, a two for one benefit.
Okay, I get excited by the simplest things. Oh, did I mention that Etomite IS a template engine? Check out commonJScripts.js to see how the alternating table rows were rendered using code that I recently wrote simply because I didn't like the way other code handled the task.
| Title | Author | Created | Edited | Longtitle |
|---|---|---|---|---|
| Home | Ralph Dahlgren | 2004-06-13 | 2008-10-23 | ralphdahlgren.com |
| Etomite CMS News | Ralph Dahlgren | 2004-07-28 | 2007-09-17 | Etomite code base development news |
| Site Map | Ralph Dahlgren | 2006-04-07 | 2007-09-10 | Links to every page on this web site |
| Code Library | Ralph Dahlgren | 2007-09-07 | 2007-09-17 | View examples of resources used to render this site |
| Search Help | Ralph Dahlgren | 2007-09-12 | 2007-12-06 | A brief explanation about effective search practices. |
| Tutorials | Ralph Dahlgren | 2007-09-12 | 2007-09-17 | Learn the hidden powers of the Etomite API |
| Ralphs Rants | Ralph Dahlgren | 2007-09-12 | 2007-12-19 | Where's my soap box? |
| Login|Logout | Ralph Dahlgren | 2007-09-20 | 2008-11-09 | Provides a visitor authentication login interface |
Sample Tag Text
Etomite "IS" a template engine, dummy!