简体   繁体   English

使用visual studio和intellisense注册扩展EJS?

[英]Registering extension EJS with visual studio and intellisense?

does anyone know how i can map EJS to visual studio to act like a HTML file.有谁知道我如何将 EJS 映射到 Visual Studio 以充当 HTML 文件。 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.我想我设法做到了,但它有很多膨胀。它基本上是一个没有 HTML 和 BODY 标签的 HTML 文件。所以我选择了 VS 2008 中的 UserControl、工具、选项、文本编辑器、文件扩展名和添加了 EJS 并将其添加为用户控件。

If i choose html then it doesn't offer intellisense until it detects a HTML and BODY ..如果我选择 html 那么它不会提供智能感知,直到它检测到 HTML 和 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.它需要为 html 和 javascript 提供智能感知,仅此而已。

Also can i create some kind of code to install the EJS automatically on another pc?我也可以创建某种代码来在另一台电脑上自动安装 EJS 吗?

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".然而,一个更简单的解决方案(我只在 VS 2013 中测试过)是右键单击任何给定的 *.ejs 文件,然后选择“打开方式”。 In the dialog that opens, select "HTML (Web Forms) Editor" and select it as default.在打开的对话框中,选择“HTML (Web Forms) Editor”并将其选为默认值。

Now, when you open your EJS files, you will get syntax highlighting and intellisense for your HTML.现在,当您打开 EJS 文件时,您将获得 HTML 的语法突出显示和智能感知。 This does not give you support for EJS Code snippets.这不会为您提供对 EJS 代码片段的支持。

I was also searching for an answer to this question.我也在寻找这个问题的答案。 Here is what I found...这是我发现的...

Source - Visual Studio 2008 - Visual Studio 2008

Obviously Visual Studio does not have support for the .blogtemplate extension.显然 Visual Studio 不支持 .blogtemplate 扩展名。 For awhile I hacked my way around it by renaming the files to have a html extension while editing, which sort of works.有一段时间,我通过在编辑时将文件重命名为具有 html 扩展名来绕过它,这是一种有效的方法。 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:为了完整起见,我也将它们包括在这里:

  1. Go to the Tools->Options menu.转到工具-> 选项菜单。
  2. Pick Text Editor -> File Extension from the tree in the left part of the Options dialog.从“选项”对话框左侧的树中选择“文本编辑器”->“文件扩展名”。
  3. Type your file extension, .blogtemplate in my case, in the Extension text box.在“扩展名”文本框中键入您的文件扩展名,在我的情况下为 .blogtemplate。
  4. Select the appropriate editor from the Editor dropdown.从编辑器下拉列表中选择合适的编辑器。
  5. 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.创建 HTML 智能感知架构文件:转到 Visual Studio 安装的common7\\packages\\schemas\\html目录。 On my machine this is: C:\\Program Files\\Microsoft Visual Studio 9.0\\Common7\\Packages\\schemas\\html在我的机器上,这是: 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复制文件html_401.xsd并将其命名为EJS.xsd
  • Open the file you just named EJS.xsd in Visual Studio or any other XML editor在 Visual Studio 或任何其他 XML 编辑器中打开刚刚命名为 EJS.xsd 的文件
  • Make the following changes to the top of the file:对文件顶部进行以下更改:
    • Replace the 2 occurrences of the text html-401 with EJSEJS替换出现的 2 次文本html-401
    • Change vs:ishtmlschema to "false"vs:ishtmlschema更改为"false"
    • Change vs:SuccinctFriendlyName to "EJS"vs:SuccinctFriendlyName更改为"EJS"
  • Add Registry entries for this new schema - You can edit the registry directly or create a *.reg text file.为这个新架构添加注册表项- 您可以直接编辑注册表或创建*.reg文本文件。 If you choose, the latter, name the file EJS.reg and add this to it:如果您选择后者,请将文件命名为EJS.reg并将其添加到其中:

Windows Registry Editor Version 5.00 Windows 注册表编辑器 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). Visual Studio 2008附带 22 个架构,这就是您将其命名为“schema23”的原因,如果您安装了 3rd 方架构编辑器,则该名称可能已经存在(如果您想确定,请检查该注册表项)。

Once this is done, restart Visual Studio.完成后,重新启动 Visual Studio。 Associate the *.ejs extension with "HTML Editor" instead of the "User Control Editor".*.ejs扩展名与“HTML 编辑器”而不是“用户控件编辑器”相关联。 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.现在,当您打开或创建扩展名为 *.ejs 的文件时,您应该会在“HTML 源代码编辑”工具栏中看到“用于验证的目标架构”下拉列表。 (if you don't see that toolbar, go to View->Toolbars->HTML Source Editing). (如果您没有看到该工具栏,请转到“查看”->“工具栏”->“HTML 源代码编辑”)。

You will notice that you can start using HTML tags without having to start with the <html> tag as your first one.您会注意到您可以开始使用 HTML 标签,而不必将<html>标签作为您的第一个标签。 Intellisense will also work for javascript inside a <script> tag. Intellisense 也适用于<script>标签内的 javascript。

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.您仍然需要返回并调整EJS.xsd文件并进行更多修改以完全按照您的要求运行。

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.一旦你解决了这个问题,你就可以创建一个简单的脚本来复制 EJS.xsd 文件并在另一台机器上创建注册表项。

( Fine Print: Always back up your registry before messing with it) 精美打印:在弄乱注册表之前始终备份您的注册表)

I had been having problems with ejs extesion .我在使用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 - 在扩展文本框中,输入 ejs
- In the Editor combobox, choose HTML Editor - 在编辑器组合框中,选择HTML 编辑器
- Click Add and then OK - 单击添加,然后单击确定
- Re-open your files - 重新打开您的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM