-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get list of tags used in document? #258
Comments
2022 UpdateThe easiest way is to follow this documentation example : https://docxtemplater.com/docs/faq/#get-list-of-placeholders Old answerThis is something that can be done using a module. Here is an example :
However, this is quite experimental, and could potentially break in future releases. |
I went for a simpler approach as I was only interested in {#groups}
but this would return an array of all tags (up to 20 chars in length):-
|
@edi9999 what is testUtils ? in your example code stated above?
|
It is just a method that creates the doc instead of doing
|
@edi9999 can you please provide some working code to get tags. |
@edi9999 here is my code
here is the error I get
|
Ok, I see, this happens becaus of a rendering error probably. Can you try to replace doc.render() by doc.compile() and see if that helps ? |
I have also updated the code above with a try / catch statement. Can you update your code and report the result ? |
@edi9999 sorry for late reply. I got error even after changing doc.render() to doc.compile().
here is the error I get
|
Can you do
just after Are you running version 3.1.11 of docxtemplater ? |
@edi9999 yes I'm using docxtemplater version 3.1.11
here is the url to gist file containing the output |
Can you update to docxtemplater 3.1.12. It should work with that version |
(I just published it) |
@edi9999 Awesome! thank you very much. please consider including getTag method to docxtemplater. |
It is now possible to get the list of tags of the document by writing less code. https://docxtemplater.readthedocs.io/en/latest/faq.html#get-list-of-placeholders |
@edi9999 awesome thank you. |
Environment
How to reproduce my problem :
Is it possible to get a list of tags used inside a document?
I want to extract all the tags so that I can ask the user some questions before I generate the doc.
The text was updated successfully, but these errors were encountered: