Let's say I have a user-generated document template with placeholders and I want to replace them with actual values.
Values could be:
So far I wrote a simple find/replace tool 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.
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):