Code generator using smarty templates