Like I mentioned before, I'm posting some of my personal code library that I've accumulated over the years. If you modify or improve this, send the changes back please.
Recursive template engine with escaping and lazy evaluation. Note that it is case SENSITIVE.
1. Add items to Templater's map.
templater.map()["bob"] = "joe";
2. Evaluate a text item that references a map item.
s = templater.eval("well, hello [!bob]");
Returns "well, hello joe" in s;