[Solved] "Try Meteor" as a package. Snag #1. Can a package export a template?


In the thread, Package Only Using Mediator Pattern , I mention beginning to try to redo the Try Meteor tutorial as a package. Yesterday, I committed a little project to GitHub : pkgd-todos. I got as far as the second step in the tutorial and hit a problem.

To get it to work, instead of adding the new code directly in the package directory, I had to first do so in a sibling directory I called modules. It works fine there, but if i move the code from modules/todos-pkg/client/todos-pkg.* to packages/todos-pkg/client/todos-pkg.html I get the error:

Uncaught TypeError: Cannot read property 'helpers' of undefined

Prior to that error I hit the complaint :

Uncaught ReferenceError: Template is not defined

However, I fixed that in my package.js file, easily enough, with :


Having got past that, I now see no way at all to make my todos template visible.

So, my first questions are conceptual – Can a package export a template to the embedding application? Or, from the other point of view, can an application “see” templates in a package? What further setting do I need in my packages.js file, to make it work?

Package Only Using Mediator Pattern

Yip - exporting templates are as easy as including the files with api.addFiles.

api.use('templating', 'client');
api.addFiles(['templates.html','templates.js'],'client'); //  Include the template before the helper. Now you can use the templates in your application.

Let me know if it worked.


I spent a half a day moping around in a when-are-you-going-to-realize-you-just-arent-smart-enough-for-this-kind-of-work mood, when the real culprit all along was skimpy documentation. Grrr!

Not to worry … it gave me a reason to offer my first Pull Request on the Meteor project : Helpful hints to poor confused n00Bz like me. :blush: