Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global objects not path-able #54

Open
soci-viii opened this issue Mar 27, 2012 · 0 comments
Open

Global objects not path-able #54

soci-viii opened this issue Mar 27, 2012 · 0 comments

Comments

@soci-viii
Copy link

Pathing only works for objects that are in a context, not the global space. I've been using this kludge-tastic helper as a workaround to resolve paths out of the global namespace. I'd like to not have to use it.

function _global(chunk,ctx,bodies,params){
    var cur= ctx.get(params.root),
      i= 0
    while(true){
        var param= params["p"+(i++)]
        if(param === undefined)
            break
        cur= cur[param]||cur.get&&cur.get(param)
    }
    chunk.write(cur)
}

It's used like this: {#global root="foo" p0="bar" p1="baz"/}

From: makeBase({foo:{bar:{baz:77}}})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant