Edit: Maybe I should make this part clear. A user is writing the template. So I want the syntax to be simple, and I can't trust them with powerful template engines.
So, I need a template engine that will be used to write emails, using tokens (easy) with conditional logic (less easy).
Example: Hello{if first_name} dear {first_name}{endif}, blah blah blah.
If first_name is not available, it should read: Hello, blah blah blah.
I was able to get it working using eval... but we all know eval is evil.
$body = preg_replace('/{if ([^{\|}]+)}/i', '<?php if(isset(\$tokens[\'$1\'])):?>', $body);
$body = preg_replace('/{endif}/i', '<?php endif;?>', $body);
Can anyone point me towards a tutorial on this one? I can't seem to find anything beyond simple token replacement.