Passing data from one template to another


Let’s say I have two templates included on a page:

{{> dataEntry }}
{{> calculations }}

And I want to take variables from dataEntry and send them over to calculations. Not stuff in MongoDB either, just variables. I know session variables are one way, but I’d rather avoid using them.


Or you can use a Local (unmanaged) Collection and use my package that allow them to persist between hot codes pushes.
Once the session has ended, all data is gone.


that’s a great idea –


I’d rather not have to use a package to do this.

So let’s say I have a ReactiveVar within a template:

Template.templateOne.onCreated(function() {
  this.myVar = new ReactiveVar(0);

And I’m using myVar within templateOne, but then I want to share this value with templateTwo. I just tried this and it seems to work, actually:

Template.templateTwo.someOtherVar = Template.instance().myVar.get();