Template engine replacement

According to Wiki, it's possible. But I can't grok how to do it really, if I want to use not own ugly function, but real template engine - current templater drive me nuts

Can anybody write small howto or just hints about "Using SMARTY as template-engine"? I undestand and can work with Smarty and with Elgg templates, can't imagine how they'll work in pair