Choosing a right algorithm for template-based text generation
You give this one a try - generation-caption-for-new-image . This has 2 parts one labeling the image and second generating text for those labeled images.
Your case is similar to this, the difference is - in your case there are templates and in this case there are images.

Please comment if you need help in understanding the code (that code is not mine, but I have gone through that in detail) or you find difficulty mapping this answer to your problem.