You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common typo I've encountered from user templates is with the LINK command, where a user misses the brackets in the command's options:
// Was
{{link {url: 'https://example.com'} }}
// Should be
{{link ({url: 'https://example.com'}) }}
If the surrounding () happens to be missed, an exception gets thrown when calling createReport:
node_modules/docx-templates/lib/xml.js:90varsegments=str.split(options.literalXmlDelimiter);^
TypeError: Cannotreadpropertiesofundefined(reading'split')atsanitizeText(node_modules/docx-templates/lib/xml.js:90:24)atbuildXml(node_modules/docx-templates/lib/xml.js:65:16)atnode_modules/docx-templates/lib/xml.js:77:20atArray.forEach(<anonymous>)
at buildXml (node_modules/docx-templates/lib/xml.js:76:24)
at node_modules/docx-templates/lib/xml.js:77:20
at Array.forEach (<anonymous>)
at buildXml (node_modules/docx-templates/lib/xml.js:76:24)
at node_modules/docx-templates/lib/xml.js:77:20
at Array.forEach (<anonymous>)
This is invalid syntax according the docx-templates docs but it's an easy mistake to overlook and it's a hard failure and even with failFast: false gets thrown separately to other in-document errors. Ideally the failure would be softer, like how missing a mismatched or missing {{ end-for }} command occurs and not throw an unhandled exception, being incorporated into other document errors.
Otherwise, if feasible, avoid requiring the brackets in the syntax would avoid them being forgotten.
When reporting a bug, please provide:
A small reproducible example consisting of the code and .docx template you used.
A common typo I've encountered from user templates is with the
LINK
command, where a user misses the brackets in the command's options:If the surrounding
()
happens to be missed, an exception gets thrown when callingcreateReport
:This is invalid syntax according the docx-templates docs but it's an easy mistake to overlook and it's a hard failure and even with
failFast: false
gets thrown separately to other in-document errors. Ideally the failure would be softer, like how missing a mismatched or missing{{ end-for }}
command occurs and not throw an unhandled exception, being incorporated into other document errors.Otherwise, if feasible, avoid requiring the brackets in the syntax would avoid them being forgotten.
When reporting a bug, please provide:
Code:
template.docx
:Node, docx-template 4.13.0
The text was updated successfully, but these errors were encountered: