Node docx-templates library does not handle IF structure

Viewed 256

I'm using the node-based docx-templates to create a word document from an spfx webpart.

I'm having issues defining the IF structure. Below structure results in an SyntaxError.

Error executing command '$question.type === 'text''. SyntaxError: Invalid or unexpected token

+++IF question.type === 'text' +++
...
+++END-IF+++

Following statement is passing, so it seems it cannot evaluate the '===' statement. I tried with double and triple '='.

+++IF question.type +++
...
+++END-IF+++

The syntax is exact the same as in the doc but I can't find any examples using the IF.

I'm wondering if it may be a bug or am I overlooking something here.

1 Answers

Try it like this

+++IF data.test_barchart_doc_gen.data != ``+++ 
+++IMAGE data.test_barchart_doc_gen+++ 
+++END-IF+++

Usually back-ticks works for these cases in the DOCX templates

Related