Raise an error when a FOR loop is not properly closed.
See original GitHub issueI can’t fill in attached template. All I get is first 4 lines of the template with filled markers and then the rest is cut.
I’m attaching the template and the data I want to put in it.
const data = {
address: 'Długi Targ 200/12, Gdańsk',
unitName: 'ACME Solutions',
date: '18.12.2020',
city: 'Gdańsk',
nip: '1234567890',
regon: '456456456',
representatives: [
{
name: 'Osoba Pierwsza',
contact: 'osoba.pierwsza@acmesolutions.pl',
},
],
paymentsFrequency: {
taxYear: '2020',
quarterly: true,
choosing: true,
},
vatTaxpayerRegistration: {
choosing: false,
registeredTaxpayerExempt: true,
},
}
Template
Prawne-oswiadczenie-PDOP-VAT.docx
More, when I remove this part of template:
+++FOR representative IN representatives+++
+++INS $representative.name+++ - +++INS $representative.contact+++
+++END-FOR representatives+++
I get an error that
Error: Error executing command 'taxYear'. ReferenceError: taxYear is not defined
at new CommandExecutionError (node_modules/docx-templates/lib/errors.js:53:28)
at Object.<anonymous> (node_modules/docx-templates/lib/jsSandbox.js:104:32)
at step (node_modules/docx-templates/lib/jsSandbox.js:33:23)
at Object.next (node_modules/docx-templates/lib/jsSandbox.js:14:53)
at /home/user/workspace/project/packages/web-server/node_modules/docx-templates/lib/jsSandbox.js:8:71
at new Promise (<anonymous>)
at __awaiter (node_modules/docx-templates/lib/jsSandbox.js:4:12)
at Object.runUserJsAndGetRaw (node_modules/docx-templates/lib/jsSandbox.js:54:12)
at /home/user/workspace/project/packages/web-server/node_modules/docx-templates/lib/processTemplate.js:478:50
at step (node_modules/docx-templates/lib/processTemplate.js:33:23)
at Object.next (node_modules/docx-templates/lib/processTemplate.js:14:53)
at /home/user/workspace/project/packages/web-server/node_modules/docx-templates/lib/processTemplate.js:8:71
at new Promise (<anonymous>)
at __awaiter (node_modules/docx-templates/lib/processTemplate.js:4:12)
at processCmd (node_modules/docx-templates/lib/processTemplate.js:435:54)
at /home/user/workspace/project/packages/web-server/node_modules/docx-templates/lib/processTemplate.js:401:38
at step (node_modules/docx-templates/lib/processTemplate.js:33:23)
at Object.next (node_modules/docx-templates/lib/processTemplate.js:14:53)
at /home/user/workspace/project/packages/web-server/node_modules/docx-templates/lib/processTemplate.js:8:71
at new Promise (<anonymous>)
at __awaiter (node_modules/docx-templates/lib/processTemplate.js:4:12)
at processText (node_modules/docx-templates/lib/processTemplate.js:370:66)
at /home/user/workspace/project/packages/web-server/node_modules/docx-templates/lib/processTemplate.js:325:42
at step (node_modules/docx-templates/lib/processTemplate.js:33:23)
at Object.next (node_modules/docx-templates/lib/processTemplate.js:14:53)
at fulfilled (node_modules/docx-templates/lib/processTemplate.js:5:58)
It just ignores the declaration of ALIASes which is just before the usage of taxYear
+++ALIAS ch1 INS paymentsFrequency.monthly+++
+++ALIAS ch2 INS paymentsFrequency.quarterly+++
+++ALIAS chosenText INS paymentsFrequency.chosenText+++
+++ALIAS taxYear INS paymentsFrequency.taxYear+++
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
Handle an exception in a while loop - python - Stack Overflow
Try something like this: def some_function(){ try: #logic to load the page. If it is successful, it will not go to except. return...
Read more >Exceptions not caught properly in while loop [closed]
Unfortunately, for some reason after the error is raised, it is not caught and the code keeps running where it was before pressing...
Read more >Python 3.8+ raises "RuntimeError: Event Loop is closed" on ...
I am experiencing this as well for anyone reading this in posterity, Windows 10 getting the event loop already closed error. The code...
Read more >30. Errors and Exception Handling | Python Tutorial
It's a loop, which breaks only if a valid integer has been given. The while loop is entered. The code within the try...
Read more >for - JavaScript | MDN - MDN Web Docs - Mozilla
for (let i = "start" in window ? window.start : 0; i < 9; i++) { console.log(i); } // SyntaxError: 'for-in' loop variable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Again, this is free software. I’m not asking you to help me fix any kind of bug, and you’re not obligated to use my work.
In your initial post you referred to
Error: Error executing command 'taxYear'. ReferenceError: taxYear is not defined
, right? There is no asterisk in your call to+++taxYear+++
. Same for+++chosenText+++
next to it. Are you referring to another template? I only have the one you sent in your earlier reply.Mind the attitude. Note that I’m helping you for free with something that looks like your job. Unless you’re working on something that processes invoices for charity, that means i am helping you make money.
Regarding your issue: see the docs on the ALIAS command. You need to resolve the alias with
*
.