Meteor dynamic url explicit template finding path instead

170 views Asked by At

I have a dynamic iron route with the template explicitly set, however iron router attempts to render the path instead of the template.

http://localhost:3000/blog/example-post

Couldn't find a template named "Blog:permalink" or "blog:permalink". Are you sure you defined it?

Router.route('/blog/:permalink'), {
  template: 'blogPost',
  name: 'blogPost',
  path: '/blog/:permalink',
  data: function () {
    return Blogs.findOne({ permalink: this.params.permalink, published: true });
  }
}

Router.route('blog'), {
  path: '/blog',
  waitOn: function () {
    return [
      Meteor.subscribe('blogs')
    ]
  }
}
1

There are 1 answers

1
Kuba Wyrobek On BEST ANSWER

You closed route ) without adding there the options object ( see , after ) ). That's why iron:router tries to generate template name from path:

Router.route('/blog/:permalink'), {

Should be:

Router.route('/blog/:permalink', {
  template: 'blogPost',
  name: 'blogPost',
  path: '/blog/:permalink',
  data: function () {
    return Blogs.findOne({ permalink: this.params.permalink, published: true });
  }
})