Set HTML syntax on file.html.js


#1

How can I tell Atom to treat all file-name.html.js files as HTML?


#2

If you don’t want to edit the language-html rules then you can add <!doctype html as the first line of the file and then it will always open using the HTML grammar. Otherwise you have to edit the atom/resources/app/node_modules/language-html/grammars/html.cson file to include html.js in the fileTypes list.


#3

Editing files in atom/resources is virtually always the wrong thing to do. These files will be overwritten on the next update to the package.

Putting the following in your init.coffee should work:

atom.workspace.observeTextEditors (editor) ->
  if editor.getPath()?.match(/\.html\.js$/)
    editor.setGrammar(atom.grammars.grammarForScopeName('text.html'))

Language Selection - Autodetect doesn't work
Set default syntax for erb files
#4

I think the file-types package would work too https://atom.io/packages/file-types