question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Raise an error when a FOR loop is not properly closed.

See original GitHub issue

I 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. image

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:open
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
jjhbwcommented, Dec 22, 2020

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.

1reaction
jjhbwcommented, Dec 22, 2020

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 *.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found