elapouya / python-docx-template

Use a docx as a jinja2 template
GNU Lesser General Public License v2.1
1.98k stars 385 forks source link

A way to trace/debug the variables substitution #512

Open cezarc opened 1 year ago

cezarc commented 1 year ago

Describe your problem

First of all - thank you very much for your brilliant work, I really appreciate! I'm looking for the way to trace/debug variables substitution.

More details about your problem

I've got {{ variable }} in the document which was working fine. Now it doesn't work and gives empty result. The template has been processes by Word and LibreOffice, so it can be a case, however in the XML it looks fine, but still in the destination document it is empty. So it'll nice to have kind of debug/trace of variables substitution.

SergeyZaykov commented 10 months ago

You don't present your Python code and Word code. It makes difficult to understand your problem.

What do you mean with "empty result"? Empty document? What should be in the document, the hundreds of variables but there aren't any variable's values? Are there an empty string instead of variable's value? I don't understand.

Well you have in your Python code some dictionary keys and you should put these keys as variables into the Word document. First of all check "dictionary key"/"variable" misspelling.

If your variable is a part of other iterable object like dictionary or list just put on your iterable object like {{ my_iterable_object }} end check misspelling.