Lookup operator to include partial on Handlebars


I've extensively searched for an answer to this, so I hope I haven't missed the obvious.

I'm using handlebars to iterate over an array of objects and choosing a partial view depending on a property on each object.

I have seen the documentation for dynamic partials as well as for the lookup operator and a number of explanations online but I can't seem to understand how the . and .. are used or relate to the current context.

I would expect the following code

{{#each data as |item|}}
    {{> (lookup item 'type') }}

to look for a type property on each object in the array and include a partial with that name, but the lookup evaluates to undefined.

I have seen examples showing this instead

{{> (lookup . 'property') }}

so my questions:

  1. What's the right way to refer to item in the lookup?
  2. What . and .. refer to?


EDIT: Added data object and template from actual code (data object has been reduced and actual entity name changed to 'item' but otherwise actual code)

From the data

    "_links": {
        "self": { "href": "/item/342" }
    "itemId": "342",
    "datetime": "2012-10-06T04:13:00+00:00",
    "itemType": "ITEM_TYPE",
    "content": {

From the template

{{#each data as |item|}}
    {{> (lookup item 'itemType') }}


    description: undefined,
    fileName: undefined,
    lineNumber: undefined,
    message: "The partial undefined could not be found",
    name: "Error"…

Found a solution. As noted by @76484:

. is alias for this and points to the currently scoped object. ../ points up one level to the parent scope's object.

The lookup in the example can be done either by

{{#each data as |item|}}
    {{> (lookup item 'itemType') }}


{{#each data}}
    {{> (lookup . 'itemType') }}

This video can help you solving your question :)
By: admin