I am trying to write some code which allows me to pass a doc as a string which is either plain txt or html and has some fields embeded i want to replace with personal values. something like for example like this
Hi {{ first_name | fallback: "there" }},
i will pass the field names as an object with same name so the lookup is easy. So what i am looking for coding ideas how to search for the {{ }} part and then check if field is not unknown, null or "" and if it is apply the fallback value in the tag. This is something like mailmerge but i dont want ths to be a docx file and output as word or pdf. i just want the processed string so i can pass back to my mail code and send message