How to use Mail Merge Foreach Blocks with Mustache template in PHP using Aspose.Words REST API

Hello Aspose Team,

We are facing an issue getting Foreach Blocks to get merged in our templates. Do you have instructions of how we should enter these merge fields?

On the other hand, should we send a certain flag or field in our request in order to have Foreach Blocks merged successfully?

Thanks.

@Softwareselskabet

Thanks for your inquiry. It seems you are populating data in foreach block of mustache template. Please check the PHP code in this documentation article. You may also test the API directly in your browser.

Furthermore, please note POST /words/{name}/executeTemplate works with Mustache Templates and POST /words/{name}/executeMailMerge works with MailMerge templates.

Hopefully, it will help you to accomplish the task. However, if there is any difference in your requirement and our understanding, then please share your sample input document, data and expected output document here. We will look into these and will guide you accordingly.

Hello @tilal.ahmad,

We are revisiting the issue now and we can see that the documentation article you are referring to is deleted. Can we find it under a new link that you could share with us?

Thanks.

Best regards,

@Softwareselskabet,

We are sorry for your inconvenience. Actually, since Aspose.Words Cloud 19.5 release, we have merged ExecuteMailMerge and ExecuteTemplate APIs. Now ExecuteMailMerge API works for both type of templates.

Furthermore, please note updated functionality is available in V4 API version.

Thanks @tilal.ahmad we will check the mentioned resources.

On the other hand, regarding the ForEach format we should use when we prepare the Word Document templates, do you have an example with that?

@Softwareselskabet

Please find attached sample Foreach Mustache document along with the data. Hopefully it will help you to start with the Foreach. Please feel free to contact us for any further assistance. SampleExecuteTemplate.zip (50.0 KB)