passing var to a template in a loop

I want to use a template to copy a file to a destination with a unique name, on each copy.
I also want to pass a unique value for a variable used in the jinja2 template file.
How can I do this?

I know I can use with_items to specify a list and thus change the destination file name on each copy,
but how can I change the variable inside the template to a corresponding value for each file name ?

To be specific, I want this file copied over multiple times with a unique name each time and I also want a variable within each copy to set to a distinct value.
e.g. dest file-name = file1 with variable in template set to var1
dest file-name = file2 with variable in template set to var2
etc.

Hi,

This is more of a user level question, would you mind posting this to ansible-project instead?

We’ll probably have some follow up questions once posted there.

Thanks!