linkedin / dustjs

Asynchronous Javascript templating for the browser and server
http://dustjs.com
MIT License
2.91k stars 479 forks source link

Context.prototype.get doesn't support nested objects #176

Closed kilianc closed 11 years ago

kilianc commented 12 years ago

var base = dust.makeBase({ a: { b: { c: 'foo' } } })
console.log(base.get('a.b.c')) // === undefined
console.log(base.get('a')) // === [object Object]
vybs commented 12 years ago

try getPath for console.log(base.get('a.b.c'))

kilianc commented 12 years ago

The problem is that dust calls get when it renders the template

Kilian C.

On Monday, October 15, 2012 at 5:47 PM, Veena Basavaraj wrote:

try getPath for console.log(base.get('a.b.c'))

— Reply to this email directly or view it on GitHub (https://github.com/linkedin/dustjs/issues/176#issuecomment-9449942).

vybs commented 12 years ago

AFAIK, when it sees a dot notation, it compiles to getPath.

{a.b.c}

function() { dust.register("demo", body_0);

function body_0(chk, ctx) { return chk.reference(ctx.getPath(false, ["a", "b", "c"]), ctx, "h"); } return body_0; })();