我如何让 Eclipse 将 .ejs 文件解释为 .html?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11035329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:22:48  来源:igfitidea点击:

how do i get eclipse to interpret .ejs files as .html?

eclipsenode.jsideexpressejs

提问by Khon

i recently started on a node project and two of the modules i'm using is express and EJS. but default i usually use eclipse as my IDE, it works well for java and decent for html and javascript. but one problem i'm having is that for .ejs files i get no markup color coding, or any form of code completion. it's basically just a plain file.

我最近开始了一个节点项目,我使用的两个模块是 express 和 EJS。但默认情况下,我通常使用 Eclipse 作为我的 IDE,它适用于 Java,适用于 html 和 javascript。但我遇到的一个问题是,对于 .ejs 文件,我没有标记颜色编码或任何形式的代码完成。它基本上只是一个普通文件。

does anyone know how i can get eclipse to interpret .ejs files as .html files? i figure it's pretty similar except for the occasional embed tags. or a recommendation for an IDE more well suited to node.js/html/ejs development.

有谁知道我如何让 Eclipse 将 .ejs 文件解释为 .html 文件?我认为它非常相似,除了偶尔的嵌入标签。或者推荐一个更适合 node.js/html/ejs 开发的 IDE。

thanks!

谢谢!

回答by rlegendi

For a specific file, try right-click, Open With -> Other... -> HTML editor. You can also set the file association globally under Window -> Preferences -> General -> Editors -> File Associations.

对于特定文件,尝试右键单击,打开方式 -> 其他... -> HTML 编辑器。您还可以在Window -> Preferences -> General -> Editors -> File Associations下全局设置文件关联。

On a Mac, the global setting is under Mac Option -> Preferencesand all the same options.

在 Mac 上,全局设置位于Mac Option -> Preferences和所有相同选项下。

回答by Andrew Martin

As an addendum to rlegendi's answer, if you'd also like the proper html coloring, you need to go to "Content Types" (right above "Editors" in the Preferences). From here, select Text -> HTMLand click on "Add..", including .ejs

作为 rlegendi 答案的附录,如果您还想要正确的 html 着色,则需要转到“内容类型”(在首选项中的“编辑器”正上方)。从这里,选择Text -> HTML并点击“Add..”,包括 .ejs

回答by Andrés Moreno

For me, the best way has been:

对我来说,最好的方法是:

Windows > Preferences > General > Content types

窗口 > 首选项 > 常规 > 内容类型

In window Content typesi've selected Text > HTML

在窗口内容类型中,我选择了文本 > HTML

and window File associationsclick Add...and i've included *.ejs

和窗口文件关联单击添加...,我已经包含*.ejs