meteorhandlebars.jsmeteor-blazespacebars

meteor dynamic template data context


This is a very simple repo, feel free to clone it to test a solution or comment on the commit if its an easy change I'm missing. https://github.com/Falieson/meteor-blaze-examples/commit/8e94f7008cecf647bb23269d9b92cbae49e2398a

I started with meteor create, tested the blaze-components package, and am now figuring out how to use {{> Template.dynamic template=childTemplate data=this }}.

The "hello" counter doesn't pass the value for the reactive variable down to the template, I thought it'd be accessible from {{#with this}} or {{this.count}}

Similarly I would expect the "info" template to render each of the links.

Thank you for your assistance!


It looks at first like there's an error where containerTemplate is receiving counterData as a variable named data but I'm trying to access it using this. When I change containerTemplate.html 's call to render the childTemplate too {{> Template.dynamic template=childTemplate data=data}} the template doesn't render.


Solution

  • All the changes I made in this commit are chasing data context passing for the wrong reasons. I wasn't receiving helper data in the rendered template but I was getting an error in my console that I thought I could ignore because it wasn't causing any issues until trying to use Template.dynamic

    modules-runtime.js?hash=8587d18…:231 Uncaught Error: Cannot find module 'meteor/templating'
    
     at makeMissingError (modules-runtime.js?hash=8587d18…:231)
    

    Removing import { Template } from 'meteor/templating'; from my main.js fixed the issue immediately.