How to access template data? (Blaze)


#1

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.


#2

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


#3

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).


#4

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


#5

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