Template data is replaced

I generate 2 templates dynamically using Blaze.renderWithData.
Data is different each time.

contactForm.each(function(index) {
  const parent = $(selector).get(index);
  const data = {email: parent.dataset.email}; // here data are different
  Blaze.renderWithData(Template.contact, data, parent);
});

When I log data in the templates’ onCreated function, the data is different. But in onRendered, the first template data is in fact replaced by the second template data.

Why is that ?

Template.contact.onCreated(function() {
  console.log('onCreated', this.data.email);
});

Template.contact.onRendered(function() {
  console.log('OnRendered', this.data.email);
});

Results:

onCreated 1
onCreated 2
onCreated 3
OnRendered 3
OnRendered 3
OnRendered 3

I just recreated your example (with the only difference of using contactForm.forEach) and the console.log is as you would expect, onCreated and onRendered log the correct values.

Ooops, it was a error on my part, I’m very sorry.
I also made a new project from scratch and… it worked…
Thank you for your time.

I simplified the original code.
The original code was:

function(data) {
    ... some code ...
    _.extend(data, {email: parent.dataset.email});
    Blaze.renderWithData(Template.orbiterSitesContactForm, data, parent);
}

At each loop the data was replaced locally but also in the template as it was a javascript reference.
When it was created the template has the correct data. But as the time he got to onRendered it was already changed. Again ,sorry and thank you !