How to access template data? (Blaze)

Hello,

I have inherited a meteor project and I have to work on it.
Sometimes template data is access like this:
this.data.createdBy
and sometimes template data is access like this:
this.createdBy

What is the difference?

Thanks.

Can you post some examples of the code you are looking at?

this.data.createdBy is used in template lifecycle callbacks like onCreated, onRendered and onDestroyed, where this is the template instance itself.

this.createdBy is used in template helpers and event maps, where this is the data context for the template instance (equivalent this.data above).

1 Like

Thanks, you are right.
Both are reactive or only this which is the data context for the template instance?

Only the template helper this.createdBy is reactive. The this.data.createdBy, where this is the template instance, is not reactive.

2 Likes