I originally wrote the JTP class as an experiment for client-side template parsing. I was pretty happy with the result and ended up further developing the JTP and integrating parts of it in some of my other work, but I did keep the original, working, JTP class which I am posting here for anyone interested. Recently, someone asked me on YouTube if there's any way he can avoid writing all that bulky html for a rounded box example I have posted there, in cases where he needs multiple boxes to appear on a page. This is exactly the reason I created JTP in the first place, more exactly, I wanted to integrate a feature that will "draw" a nice shadowed frame around image thumbnails, for my image preview navigation class, and why do that only for images when you can do it for any html blocks. To view a working demo of JTP with example and instructions, please check it out on my work website at http://www.crissleonte.com/JTP/ . You can download the entire content of the JTP folder, as a .zip archive from http://www.crissleonte.com/JTP/JTP.zip . You only need 3 javascript file inclusions to run JTP and no additional javascript code. Those 3 files can be compiled into a single file and they can also be reduced in size since the functions.js file contains many functions which are not used by JTP. Once you have included the scripts on the page, JTP will run automatically when the page has finished loading, and it will process all special JTP commands set within the page as plain html comments. View the demo for details and an explanation of how JTP works. Note that the JTP class provided in the demo is a raw, unpolished version which is not intended to be used as it is, but only serve as an example and a starting point for more advanced versions. The demo JTP contains one major known bug, the script may end up in an infinite loop if the HTML of the page is badly nested, the method that iterates through the comment nodes can be re-written into a much better, error-proof version. That's about it. You can probably find other javascript template parser scripts on the web, I haven't bothered checking. If you don't have the time to go through the code of JTP and write your own stuff you'll probably want to check the web first for something similar. I will probably post a "gold" version of JTP when I finally get myself to pull all code components I currently have integrated within a larger project, but you can never know when that will happen so for now you're better off with the two options above. Whatever you do, I hope you'll find this useful in any way. P.S. I also attached the zip archive containing the demo to this page, check the attachments section below. |