Utilizing this specific library, I am implementing a feature to substitute placeholders within a docx template and generate multiple documents. The technologies involved are neutralino and vue for the front-end, where I have devised a method that transmits the chosen docx file along with the necessary data to the library for processing. To populate the placeholders, I have structured a loop in the following manner:
// assembling all required data into an array
for(let i = 0; i < this.selectedData.length; i++){
this.dataPlaceholders.push({
key1: val1,
key2: val2
})
}
//invoking the library to produce documents
for(let i; i < this.dataPlaceholders.length; i++){
this.docxTemplate.process(template, this.dataPlaceholders[i])
}
The merged data comes from two arrays, and upon console logging them, it is evident that everything is properly arranged. Per the documentation instructions, I've utilized curly brackets {}
for placeholder designation, matching each placeholder name with the keys in the dataPlaceholders
array. Upon experimentation, while I managed to create distinct documents, the placeholders remained untouched resulting in empty fields within the documents.
What steps can be taken to rectify this issue and ensure proper functionality?