Let's say I have a user-generated document template with placeholders and I want to replace them with actual values. Values could be: * scalars * tables * ...? So far [I wrote a simple find/replace tool](https://github.com/eduard93/Utils/blob/master/Utils/RTF.cls.xml) that works with RTF format (because it's not a binary format), here's how it works:
set template = "D:\Cache\RTF\template.rtf"
set var("%title") = "Hello"
set var("%table") = $lb("Utils.RTF", "TestFunc")
set result = "D:\Cache\RTF\out.rtf"
set sc = ##class(Utils.RTF).replace(template, .var, result)
There should be two placeholders in RTF template: %title and %table and the are replaced with "Hello" and  results of Test query from Utils.RTF class, serialized into a table. Template: ![](/sites/default/files/inline/images/snimok_43.png) Output: ![](/sites/default/files/inline/images/snimok2_2.png)   But I'm wondering if someone has already done something similar and can recommend a better approach? What I'm most interested in is how do you work with preset tables, i.e. I have this template and need to produce the output above (instead of one %table template where I generate everything, part of the table is already present): ![](/sites/default/files/inline/images/snimok3.png)