Packages: ES2015 (ES6) Syntax highlighting in template literals (i.e. instead of string concatenation)

Created on 24 Sep 2016  路  4Comments  路  Source: sublimehq/Packages

Using ST3 build 3125 x64 in win10 x64.
For example (from here)

var str = "Hello, " + name + "!";
var str = `Hello, ${name}!`;

Here is how it's highlighted in ST3: (see the name variable in line 2)
2016-09-24_182558

And, for reference, here is in VSCode 1.5.3, i.e. correctly:
2016-09-24_182809


And another example:

let arr = [], temp;
$.each(arr, (index, value) => {

    arr[index].innerHTML = '(' + temp + ') ' + arr[index].innerHTML;
    arr[index].innerHTML = `(${temp} ) ${arr[index].innerHTML}`;
});

In ST3: (see both temp and arr[index].innerHTML in line 5)
2016-09-24_183030

and for reference, here is in VSCode:
2016-09-24_184055



Related issue: #213

Most helpful comment

Iirc @wbond wanted to clear the string scope name (using clear_scopes) for embedded expressions like these.

All 4 comments

This is more to do with your color scheme than Sublime itself.

Mine is showing as:
screen shot 2016-09-24 at 10 15 19 am

with the declarations:

<dict>
    <key>name</key>
    <string>JS Template Expression Definition</string>
    <key>scope</key>
    <string>string.template.js punctuation.definition.template-expression</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#515151</string>
    </dict>
</dict>
<dict>
    <key>name</key>
    <string>JS Template Embedded Expression</string>
    <key>scope</key>
    <string>string.template.js source.js.embedded.expression</string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#d3d0c8</string>
    </dict>
</dict>

I'm using the Monokai scheme (=the default one) which is in its initial status (I haven't modified it at all),

Iirc @wbond wanted to clear the string scope name (using clear_scopes) for embedded expressions like these.

Was this page helpful?
0 / 5 - 0 ratings