meteor-jade icon indicating copy to clipboard operation
meteor-jade copied to clipboard

pathFor does not work with obj properties

Open ChrisCinelli opened this issue 9 years ago • 4 comments

JS:

Template.nav.helpers({
  navItems: function () {
    return [
      {
       name: "Item1",
       route: "Item1.show",
      },
      {
       name: "Item2",
       route: "Item2.show", 
      }]
  }
});

nav.jade

template(name="nav")
  ul.nav
    each navItems
      li.nav-item
        a.nav-item-name(class=selected href=pathFor(route))= name

Error:

=> Errors prevented startup:

   While building the application:
   client/templates/nav.jade: Jade syntax error: Expected identifier, number,
   string, boolean, or null
   {{pathFor(route)}}
   ^
   packages/compileJade/plugin/handler.js:xx:1: Cannot read property 'head' of
   undefined (compiling client/templates/nav.jade) (at fileModeHandler)

ChrisCinelli avatar Jul 26 '15 10:07 ChrisCinelli

I've modified a fork of this package to support passing arguments to attribute helpers, together with a few other useful features. The fork has been released as dalgard:jade.

I will keep the new package in sync with the original, should there be any updates, and generally continue maintenance until, hopefully, the two packages can be merged.

dalgard avatar Oct 14 '15 10:10 dalgard

+1

uinz avatar Dec 09 '15 17:12 uinz

Just use a(href="{{pathFor route}}") in your jade file.

laurentpayot avatar Dec 09 '15 21:12 laurentpayot

this worked for me: {{pathFor 'myTemplate'}}

takahser avatar Jan 14 '16 18:01 takahser