简体   繁体   English

index.ejs 与 index.html

[英]index.ejs VS index.html

I recently started learning nodejs and now i am very confused between what to use for my web app, html or ejs (Express).我最近开始学习 nodejs,现在我很困惑在我的网络应用程序、html 或 ejs (Express) 中使用什么。 Ejs uses the Express module whereas the .html uses the HTML module. Ejs 使用 Express 模块,而 .html 使用 HTML 模块。 My first question is, what are the differences between them if exact websites can be made from both.我的第一个问题是,如果两者都可以制作出确切的网站,那么它们之间有什么区别。 The second question, that extends from my first question is what should one use for a website that is to be uploaded to the cloud.第二个问题,从我的第一个问题延伸而来,是一个要上传到云的网站应该使用什么。 .html or .ejs. .html 或 .ejs。 I believe .ejs is dynamic (if statements can be used inside the file) therefore .ejs should be used.我相信 .ejs 是动态的(如果可以在文件中使用语句),因此应该使用 .ejs。 But, on the other hand, its the first time I am hearing this .ejs name, and I am uncertain as to what future it holds, whereas HTML has a build up name, and most developers and the market knows what it is.但是,另一方面,这是我第一次听到这个 .ejs 名称,我不确定它的未来会怎样,而 HTML 有一个建立的名称,大多数开发人员和市场都知道它是什么。 Thanks in advance.提前致谢。

Ejs is a template engine. Ejs是模板引擎。

It makes possible for you to load data from your application in the view. 这使您可以从视图中的应用程序加载数据。

After the template is rendered, it generates a .html file for the browser. 呈现模板后,它将为浏览器生成一个.html文件。

Answer 1: index.ejs allows you to execute JavaScript inside html element.答案 1:index.ejs 允许您在 html 元素中执行 JavaScript。 For example: loop or perform arithmetic operation.例如:循环或执行算术运算。 index.html can't include JavaScript inside its elements. index.html 不能在其元素中包含 JavaScript。

Answer 2: of course, index.ejs will come to my mind first.答案 2:当然,我首先会想到 index.ejs。 If you learn php, it is the same.如果你学过php,也是一样的。 php developers use index.php instead of index.html php 开发者使用 index.php 而不是 index.html

Answer 3: you don't have to worry, there are plenty of supports from JavaScript community today.答案 3:你不用担心,今天 JavaScript 社区有很多支持。

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

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