Registering extension EJS with visual studio and intellisense?

前端 未结 4 922
春和景丽
春和景丽 2021-02-19 03:07

does anyone know how i can map EJS to visual studio to act like a HTML file. I think i managed to do it but its got a lot of bloat in it.. Its basically an HTML file without the

4条回答
  •  别跟我提以往
    2021-02-19 03:51

    This requires creating a custom intellisense and validation schema. Here are the steps on how to go about doing that.

    • Creating an HTML intellisense schema file: Go to the common7\packages\schemas\html directory of your Visual Studio installation. On my machine this is: C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\schemas\html
    • Make a copy of the file html_401.xsd and name it EJS.xsd
    • Open the file you just named EJS.xsd in Visual Studio or any other XML editor
    • Make the following changes to the top of the file:
      • Replace the 2 occurrences of the text html-401 with EJS
      • Change vs:ishtmlschema to "false"
      • Change vs:SuccinctFriendlyName to "EJS"
    • Add Registry entries for this new schema - You can edit the registry directly or create a *.reg text file. If you choose, the latter, name the file EJS.reg and add this to it:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{1B437D20-F8FE-11D2-A6AE-00104BCC7269}\Schemas\Schema23]
    "File"="html\\ejs.xsd"
    "URI"="http://schemas.microsoft.com/intellisense/EJS"
    "Friendly Name"="EJS"
    

    Visual Studio 2008 ships with 22 schemas, that's the reason why you this as "schema23", if you installed a 3rd party schema editor, that name may already exist (check that registry key if you want to be sure).

    Once this is done, restart Visual Studio. Associate the *.ejs extension with "HTML Editor" instead of the "User Control Editor". Now, when you open or create a file with a *.ejs extension, you should see the "Target Schema For Validation" drop down in the "HTML Source Editing" toolbar. (if you don't see that toolbar, go to View->Toolbars->HTML Source Editing).

    You will notice that you can start using HTML tags without having to start with the tag as your first one. Intellisense will also work for javascript inside a

提交回复
热议问题