Skip to content
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

Unique table cells are removed if they evaluate a falsy condition #382

Open
blancham opened this issue Aug 30, 2024 · 2 comments
Open

Unique table cells are removed if they evaluate a falsy condition #382

blancham opened this issue Aug 30, 2024 · 2 comments

Comments

@blancham
Copy link

What

I found a regression introduced since v4.12.0, table cells that contains a condition that is evaluated as falsy are removed when templating (it was not the case in v4.11.5)

Steps to reproduce

NOTE: my delimiter is ##
I have a table in my docx file that looks like this :
Screenshot 2024-08-30 at 12 27 19

In v4.11.5 the cells are empty (because the condition is falsy), that's what we want :
Screenshot 2024-08-30 at 12 28 31

But when I upgraded to v4.13.0 I found that this was not quite the case anymore :
Screenshot 2024-08-30 at 12 27 29

After investigating, v4.12.0 seems to be the culprit.

Code

import createReport from 'docx-templates';
import fs from 'fs';

const template = fs.readFileSync('template.docx');

const buffer = await createReport({
  template,
  cmdDelimiter: "##",
});

fs.writeFileSync('output.docx', buffer)

output-4.11.5.docx
output-4.13.0.docx
template.docx

@SuchiraD
Copy link
Contributor

@blancham , were you able to find a work around?

@blancham
Copy link
Author

Unfortunately (for you) I didn't even try, I downgraded my version.. 🙄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants