microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.34k stars 28.9k forks source link

Add .EJS support or extend existing HTML to include .EJS #2853

Closed Thomastasa closed 8 years ago

Thomastasa commented 8 years ago

Feature Request: .EJS support

Can you please add EJS support or extend the existing HTML to include .EJS files? I know it takes time to do the custom syntax highlighting, but in the meantime can you at least have .EJS files open with the .HTML template?

Below is my current fix, for anyone interested. It has to be re-applied after each version update, which is why i am asking if you could just add .EJS to the list of extensions/aliases for HTML.

VSCODE_DIR: win: c:\Program Files(x86)\Microsoft VS Code mac: Applications > Visual Studio Code.app > right click > show package content

open VSCODE_DIR\resources\app\extensions\html\package.json and add ".ejs" to extensions array and add "ejs" to aliases array.

here is a copy of how my package.json file looks after the change (on version 0.10.8 - older versions use a different file scheme):

{
    "name": "html",
    "version": "0.1.0",
    "publisher": "vscode",
    "engines": { "vscode": "*" },
    "contributes": {
        "languages": [{
            "id": "html",
            "extensions": [ ".html", ".htm", ".shtml", ".mdoc", ".jsp", ".asp", ".aspx", ".jshtm", ".ejs" ],
            "aliases": [ "HTML", "htm", "html", "xhtml", "ejs" ],
            "mimetypes": ["text/html", "text/x-jshtm", "text/template", "text/ng-template"]
        }],
        "grammars": [{
            /* "language": "html", not yet enabled*/
            "scopeName": "text.html.basic",
            "path": "./syntaxes/HTML.plist"
        }]
    }
}

Here are the docs for .EJS which shows default syntax incase you ever add syntax support for EJS: http://www.embeddedjs.com/

aeschli commented 8 years ago

In the March release we have user definable file association (see #3612). So you will be able to associate EJS files to the html language mode. Adding ejs to the html languages contribution point by default is IMO not a good idea as, if I understand correctly, EJS files are not always valid HTML files.

iongion commented 8 years ago

What about this use case ?

(function(scope){
  var configuration = <%- JSON.stringify() %>;
  scope.RUNTIME_CONFIGURATION = configuration;
})(this);

Where the file gets saved as configuration.js.jst

This is not html, it is javascript with ejs embeded inside, so an EJS mode still is a nice to have