Skip to content

What is a valid identifier? #26

simevidas opened this Issue Sep 16, 2012 · 3 comments

3 participants


The "expressions" page states:

To reference a property that is not a valid identifier, you can use segment-literal notation

However, nowhere on that page it is defined what a valid identifier is.

In JavaScript, it's a word consisting of letters, digits, $, or _, with the exception that it cannot start with a digit. Is it the same for Handlebars? It would be useful if this information were provided on the site.

dandv commented Oct 7, 2012

WTF is a "segment literal notation"? Other than a Google bomb, that is. The only two Google search results for that string are the expressions page, and this GitHub issue.


@dandv LOL I did not notice that. The handlebars-site explains what it is. In JavaScript, property names can be any string, i.e. the property name can contain any sequence of characters. Identifiers, on the other hand, are restricted to letters, digits, and the _, and $ characters. So, in order to denote a property name that is not a valid identifier, the bracket-notation, a.k.a. subscript-notation can be used, e.g. obj[ 'Not a valid identifier!!!' ]. The OP uses the term "segment-literal notation". Since that term doesn't appear anywhere else on the Internet, it appears to be an invention of the OP :P... probably a lapsus memoriae.

dandv commented Oct 8, 2012

Thanks @simevidas :) I sort of figure out what it meant, though the example on the website introduced a period after the object: articles.[10].comments. Filed #27 for that.

Would be great if @wycats could check out GitHub... a bunch of low-hanging fruit here to fix, but would help new users stumble less.

@kpdecker kpdecker was assigned May 31, 2013
@kpdecker kpdecker added a commit that closed this issue May 31, 2013
@kpdecker kpdecker Document id token characters
Fixes #26
@kpdecker kpdecker closed this in 7c2c013 May 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.