I don't like to show people my code while it's still in Beta, so I won't post it (sorry). But I'll give you an explanation of what I did.
I have a class (called template). I have the following functions:
load_template: Loads a template and saves the contents of the template file in a variable.
assign_vars: Assigns variables onto the template. For example, if you compare it to phpBB's template engine, it's the same thing as assign_block_vars.
parse: This is the function I call to compile the whole thing, and all it does is calls all the nessessary functions and echoes the output.
compile: The big function. This does everything that makes it a template engine. First, I used a bunch of preg_replace functions to find and replace if, else and loop statements in the template. Then it breaks the code up into lines and turns the needed lines into PHP code, which is eval()'d.