You can use the FillTemplate to start replacing the input string using a given object structure.Make sure to call ToObject(MyRecordOrEntityOrListOrWhatever) when inputting it to the function.
You can use foreach loops, very simple if logic, variables, records, lists, structures, entities, you name it!