wycats/handlebars.js — pull request #415 by leshill (2013-01-22 04:51:48+00:00)
Title: Add resolve mode as companion to string mode

Hi @wycats,

(This is my take on my somewhat hurried email the other day.)

Passing the resolve flag as an option uses the resolve helper to
evaluate paths in the given context. For example, given the mustache
`{{simple.path}}`, the resolve helper will be called and given the
string `simple.path` to resolve.

Resolve mode, like string mode, is intended as a hook for
`handlebars.js` to allow for more varied use cases.

Like string mode, resolve mode does not evaluate a path against the context and return the resulting value. Instead the path is captured and given to a `resolve` helper who has the responsibility for determining the resulting value.

This gives us an opportunity to do something more than just evaluate the path. For example, `ember.js` might use this to enable the `bindAttr` functionality (my recollection is that `ember.js` was transforming `{{simple.path}}` into `{{bindAttr 'simple.path'}}`.)

The default `resolve` helper resolves the path against the context. The
result is identical to the value of the path when not using resolve
mode. If you are using resolve mode, you are going to
write your own resolve method that will do something more than the
default `resolve` helper.

n.b. When writing your own resolve helper, you will want to evaluate
against the context passed along to the helper (`options.contexts[0]`).