Great question Kevin.
I have answered it in detail in this post:
https://dogmatix.medium.com/replace-text-in-google-spreadsheets-with-apps-script-ii-ddd1b544ca10
I like the idea of using it with templated Sheets.
If you tell me more about how you used this, I could another post on this. And it may help others.
Good luck.