Helper function throwing a "Could not find property" error #485

rbucker opened this Issue Apr 7, 2013 · 7 comments


None yet

3 participants


I have a helper function that looks like this:

Handlebars.registerHelper('json', function(context) {
    return Handlebars.SafeString(JSON.stringify(context));

It's executed when my module loads... so I assume that it's getting stored in the root of the namespace in the Handlebars instance.

But when I try to access the Helper from inside an #each it throws an exception:

{{#each items}}
    {{{json item}}}

however if I prefix the json with ../ it seems to work properly.

{{#each items}}
    {{{../json item}}}

I even recall seeing the same error, however, it had some ember cruft that I could not make sense of in order to work my issue... but someone suggested the following (untested)

{{#each item in items}}
    {{#with item}}
       {{{json item}}}

I hope this is enough info.


CORRECTION: {{{../json item}}} does not throw an exception but it does not work. Furthermore the suggested solution does not work either.


Do you have a stack trace?


Alternatively could you put this up in a jsbin?


Error: /Users/rbucker/ycore/lib/views/yrest_api.hbs: Could not find property 'json'
at Object.toString (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/base.js:35:11)
at program23 (eval at (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/compiler/compiler.js:554:25), :163:108)
at Object.fn (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/runtime.js:66:14)
at Object.Handlebars.registerHelper.fn (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/base.js:129:20)
at program6 (eval at (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/compiler/compiler.js:554:25), :83:26)
at /Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/runtime.js:66:14
at Object. (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/base.js:102:21)
at Object.eval (eval at (/Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/compiler/compiler.js:554:25), :202:25)
at /Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/runtime.js:30:33
at /Users/rbucker/ycore/node_modules/hbs/node_modules/handlebars/lib/handlebars/compiler/compiler.js:1266:21


I think I need a jsbin to properly debug that, all that the trace is telling me is it was not able to find the helper but I'm not sure what the call is.


I tried to get this to repeat in jsbin but was not able to (I did not see where jsbin imported handlebars. I then coded a small nodejs sample and it mostly worked. I did some more reading and I discovered MY problem. It might be helpful to add this to the FAQ under expressjs.

"if you want to register a helper that is going to be used when rendering 'hbs' templates that are configured via expressjs then you need to use the same instance to register your helpers. Else they are likely to omitted and throw PROPERTY NOT FOUND exceptions".

@rbucker rbucker closed this Apr 7, 2013

@rbucker881 could you give a clue in how to resolve this issue?

I'm running it with expressjs and my helper is not found.

In my template:

    {{#each currentRunningEvents}}
          {{#link-to 'event' this}}
            {{#if logo_url}}
              <img {{bind-attr src='logo_url'}} class="header">
            <span class="header-event-date">{{formatDate starts_at}}</span>

In my helper:

default Ember.Handlebars.registerHelper('formatDate', function(date) {
  return moment().zone(moment(date).format()).format('YYYY-MM-DD  h:mm a');

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment