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

can't access "this" property #967

Closed
75lb opened this issue Feb 22, 2015 · 4 comments
Closed

can't access "this" property #967

75lb opened this issue Feb 22, 2015 · 4 comments
Labels

Comments

@75lb
Copy link

75lb commented Feb 22, 2015

i'm trying and failing to access the this property in my context.. my context object looks something like:

{  this: "whatever" }

but i can't access the value "whatever".. i have tried all these template variations:

{{this.this}}
{{this/this}}
{{this.[this]}}

or is there another way?

@waynedpj
Copy link

i am no expert, but i believe this is a reserved word in JavaScript and has a special meaning. try using another key for that property.

@75lb
Copy link
Author

75lb commented Feb 23, 2015

this is a reserved word, the string value "this" is not.. it is a perfectly valid property name, just as "return", "if", "break" etc. are all valid property names.

@kpdecker kpdecker added the bug label Feb 28, 2015
@kpdecker
Copy link
Collaborator

This is a bug. It should resolve the property if using {{[this]}} or {{this.this}} syntax but something in the parser treats any references to this as a scope lookup.

./print-script "{{[this]}}"

Source:
1 '{{[this]}}'

Generated:
{"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
    return this.escapeExpression(this.lambda(depth0, depth0));
},"useData":true}

Map:
{"version":3,"sources":["input.hbs"],"names":[],"mappings":"AAAA,yCAAE;AAAA,IAAF,0DAAE;AAAA,CAAF","file":"output.js"}

@kpdecker kpdecker added this to the 3.0.1 milestone Feb 28, 2015
@kpdecker kpdecker modified the milestones: Next, 3.0.1 Mar 24, 2015
@kpdecker
Copy link
Collaborator

Released in 3.0.2

@kpdecker kpdecker modified the milestone: Next Apr 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants