Steering racks + Meteor + iron router

I use an iron router for my meteor project, and everything is going well, but I just ran into some weird behavior.

I have a loop configured for a list of elements that looks something like this.

{{#each list_items}}
  <div>{{user.username}}
    <a href="{{link}}">Click here!</a>
  </div>
{{/each}}

The JSON object for my user looks something like this:

{
  user: {
      username: jdoe
    },
  images: {
    low-res-url: http://example.com
  },
  link: http://example.com/profile
}

Now {{user.username}} displays as expected, but when I try to put {{link}} in href, I get an error from iron-router saying

"You called Router.path for a route named undefined but that that route doesn't seem to exist. Are you sure you created it?" 

Any help or advice would be appreciated.

+4
source share
2 answers

The handelbars helper is registered under the hood of the Iron-Router:

Handlebars.registerHelper('link', function (options) {                          
  ...
}); 

Just change the field linkto another name, for example my_link.

+5

@perhelium, Iron-Router 'link'

Handlebars.registerHelper('link', function (options) {...});

'link' JSON, JSON.

, : <a href="{{link}}">Click here!</a>

<a href="{{this.link}}">Click here!</a>

+4

All Articles