Tarlen
Tarlen

Reputation: 3797

Meteor can't find template defined in package

I am creating a package that should make a layout template available in the application

package/client/templates/boxesLayout.html

<template name="boxesLayout">
  <div class="wrapper">
    <h1>Test</h1>
  </div>
</template>

package/package.js

Package.onUse(function(api) {
  api.versionsFrom('1.0.4.1');

  api.addFiles([
    'client/templates/boxesLayout.html'
  ]);

  api.addFiles('boxes.js');
});

However, when I try to set the layout in a route like this

InboxController = BaseController.extend({
  layoutTemplate: 'boxesLayout',

I get an error saying the layout is not defined, any ideas?

Upvotes: 2

Views: 455

Answers (1)

David Weldon
David Weldon

Reputation: 64312

You need to use templating in order for a template to be exposed via a package. Modify your package.js to look something like the following:

Package.onUse(function(api) {
  api.versionsFrom('1.0.4.1');
  api.use('templating', 'client');
  api.addFiles('client/templates/boxesLayout.html', 'client');
  api.addFiles('boxes.js', 'client');
});

Note that the example adds your files only to the client, which makes sense for templates.

Upvotes: 3

Related Questions