guigrpa / docx-templates

Template-based docx report creation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preprocessing of docx template?

koosvanderkolk opened this issue · comments

My use case is that I would like to let 'less technical' end-users create their own templates.

E.g. let them create

image

Which should then be converted to:

image

I also have quite some variables which contain HTML. For those, I want the end-user to just add

image

Which should then be converted to

image

So the feature request would be to have a preprocess function, in which I can alter the template before it is being interpreted.

I don't think it is wise to implement this in docx-templates, as that would add yet another layer of configuration and complexity.

You can probably do 90% of what you want by using a custom runJs function. See e.g.

runJs: ({ sandbox }) => {