Jump to content


Photo

php template engine


  • Please log in to reply
2 replies to this topic

#1 joshman13

joshman13
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 28 February 2006 - 02:00 PM

hello everyone,
i am looking at building a lightweight template engine for some of my
scripts that i am using. i have looked into several different ones, and
although many have great features, none have exactly what i am looking
for. the main thing i haven't liked is that most of them use
{placeholder} style tags, which creates unnecessary overhead, because
php itself is a template language, so why create a wrapper for
something that already does the job?

for most of the pure php template classes, this is what i've seen for
the most part:

: assign variables that replace content
: start an output buffer
: include the template file
: store the rendered content of the template file in a varable
: clear the output buffer
: return the rendered content

i really like this format just because it allows sub-templates in a
main file. for instance, i can have a template file for the complete
shell, but then have another file to include everytime i want a table,
or a menu, or anything modular like that.

i was thinking about this though, and basically the entire page is
stored in a variable before the output is ever sent to the screen. are
there any drawbacks to doing it this way? what about speed and memory?
are there better ways to go about it?

#2 ttocskcaj

ttocskcaj
  • Members
  • PipPipPip
  • Advanced Member
  • 184 posts
  • LocationNew Zealand

Posted 01 April 2011 - 02:51 AM

Template engines such as smarty cache the pages as pure html. So the page is only drawn the first time, or if it changes.

#3 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 01 April 2011 - 06:28 AM

try mustache for PHP

https://github.com/b...ow/mustache.php
Registered Linux User #399942
Ubuntu User #14134
--
my blog




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users