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 HTML and BODY tags.. so i selected the UserControl in VS 2008, tools, options, Text Editor, file extension and added EJS and added it as usercontrol.
If i choose html then it doesn't offer intellisense until it detects a HTML and BODY ..
My question really is can i add to this list? and create my own?? It need to offer intellisense for html and javascript but nothing more.
Also can i create some kind of code to install the EJS automatically on another pc?
For what it is worth at this point...
The above solutions are still valid. However an easier solution (that I have only tested in VS 2013), is to right-click any given *.ejs file, and Select "Open With". In the dialog that opens, select "HTML (Web Forms) Editor" and select it as default.
Now, when you open your EJS files, you will get syntax highlighting and intellisense for your HTML. This does not give you support for EJS Code snippets.
I was also searching for an answer to this question. Here is what I found...
Source - Visual Studio 2008
Obviously Visual Studio does not have
support for the .blogtemplate
extension. For awhile I hacked my way
around it by renaming the files to
have a html extension while editing,
which sort of works. The main problem
is that I keep forgetting to change
the extension back before I start
testing my changes - so this was
causing unnecessary pain... I had a
vague memory of configuring something
like this before and found these
instructions. For the sake of
completeness I include them here also:
- Go to the Tools->Options menu.
- Pick Text Editor -> File Extension from the tree in the left part of the
Options dialog.
- Type your file extension, .blogtemplate in my case, in the
Extension text box.
- Select the appropriate editor from the Editor dropdown.
- Click Add and then Ok to close the dialog and re-open your files.
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 <html>
tag as your first one. Intellisense will also work for javascript inside a <script>
tag.
This is not a complete solution, but it will put in the right direction to achieve your end goal. You will still need to go back and tweak the EJS.xsd
file and make more modifications to get to behave exactly as you want it.
Once you get that sorted out, you can create a simple script that copies the EJS.xsd file and creates the registry key in another machine.
(Fine Print: Always back up your registry before messing with it)
I had been having problems with ejs extesion. I solved it like this:
- Open the menu, Tools >> Options
- In the left side, expand the option Text Editor and choose File Extension
- In the Extesion text box, type ejs
- In the Editor combobox, choose HTML Editor
- Click Add and then OK
- Re-open your files