[smarty mode] Rewrite, Smarty 3 support added

Issue #956