Move SubstituteTextPattern to smarty module, and call stash with safe=true