My name is Kenneth and I write cool Mac and iPhone software. This is my personal weblog where I post about stuff I find interesting. I usually write about Mac development, the business of shareware and the Mac community in general.read more →
Let me say this first: I do not believe in big bloated MVC PHP frameworks. I believe in having custom code that runs as fast as possible. For recurring useful functionality, such as templates, I believe in using simple, efficient and flexible dedicated standalone modules.
For the past several years, I have been using a home-grown templating system that functioned by parsing template files which would have a dedicated / invented syntax. It would replace, for example, %TAG%, with a value. It had several more advanced features too, such as conditionals, recursion, embedded PHP, and more.
And while it functioned just fine, it implemented a custom parser, and required templates to be written using a non-standard syntax. But, after having used Ruby on Rails, I was inspired to design something better.
ATTemplate is the result of this. The main idea behind ATTemplate is that PHP in itself is already a parser, so why reinvent the wheel?
ATTemplate is very lightweight and relatively simple, but it’s very powerful without being bulky. It allows for everything the other templating systems can do, including loops, nested templates, recursion, conditionals, etc.
How to use
Here’s how you’d use ATTemplate:
And here’s what your template could look like:
Welcome, You have unread messages! You have received friend requests from the following people: (has followers) The time is …
You’re free to use the code in whatever you want, commercial or not. Modify it, redistribute it, do whatever you want with it.
The only requirement is that you need to give me credit.
Also, please do shoot me an email if you use this in your project.
This entry was posted on Wednesday, July 1st, 2009 at 12:13 pm and is filed under English, Programming, Release, Web Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Add your thoughts!