test.js is an example JS file that uses template strings to test editor syntax highlighting behavior.
Specifically, it tests if the editors can syntax highlight the HTML and CSS in the strings as HTML and CSS, if the tagged template string function ends in (case-insensitive) html or css, respectively.
By targeting tagged template functions and looking at the suffix of the name, it gives us a hint to the content type inside the string, similar to a mime type. For security purposes, HTML and CSS should be escaping programmatic values (the stuff in the ${expression} parts), so using a function for a tagged template string will be commonplace.
Out of the possible parts of a JS function name to use for indicating the string type, it seems using the suffix, ending part of the function name makes the most sense: it is closest to the string value, and shoudl be a clearer, simpler regexp to use for syntax highlighting. If a developer wanted to get this syntax highlighting, but the tag function name was not the correct form, it is easy enough to create a local variable like var html = htmlify then use the html for the tagged template use.
- GitHub source code display
- Atom editor, once an Atom update ships with v0.108.0 or later of the atom/language-javascript package.
If you know of others, send the repo a pull request, ideally with a screenshot showing how test.js is displayed in the editor, and we can add it to this list.
- Native Package: sublimehq/Packages#179
- JavaScriptNext package: https://github.com/Benvie/JavaScriptNext.tmLanguage/issues/134
Default syntax file seems old, dated 2013, so no es2015 support. Seems like plugins are used instead. Need to investigate which ones are commonly used. From conversations on twitter, in no particular order: