guigrpa / docx-templates

Template-based docx report creation
MIT License
882 stars 145 forks source link

ReferenceError - skipp missing commands or replace them with something #380

Closed vectorkovacspeter closed 4 weeks ago

vectorkovacspeter commented 4 weeks ago

Not a bug, but a feature request:

If the template has a cmd, and the data or additional function not presented for it, it would be nice if can be configurable the behaviour.

In some cases its practical to replace the missing cmd with nothing (or the specified string or expression), and not giving error.

Another nice behavior can be if the createReport function has a callback that return boolean indicates that an error shuld be triggered or not. In this way you can create some kind of "required" logic if you want.

jjhbw commented 4 weeks ago

You can already do that by providing your own execution context using runJs. Each command in the doc will run in a function that you control. You can then implement error handling according to your needs. Feel free to reopen if this is not what you meant.