ractivejs / ractivejs.github.io

https://ractive.js.org
8 stars 33 forks source link

Why is single backslash used everywhere in the documentation instead of double backslash? #96

Closed ceremcem closed 7 years ago

ceremcem commented 7 years ago

Ractive uses a single backslash (\) as the escape character in the strings but if we want to include a single backslash in the string, we should use double backslash (\\).

Why does documentation contain single backslash strings in the examples?

For example, in Ractive.splitKeyPath() section, we have the following example:

Ractive.splitKeypath( 'foo.bar\.baz' ); // [ 'foo', 'bar.baz' ]

But this does not produce ['foo', 'bar.baz']: playground

Correct form should be Ractive.splitKeypath( 'foo.bar\\.baz' ), or am I missing something?

fskreuz commented 7 years ago

I'm also no expert in this area, since I generally avoid invalid characters on my keys or can never have them at all and never had to escape keys. You might want to check the unit tests tho, it might give hints.

MartinKolarik commented 7 years ago

@ceremcem is right here. You need two backslashes because one's eaten by JS.

fskreuz commented 7 years ago

one's eaten by JS

👻