express 模板引擎
If you’ve worked with the Express.js framework in the past, you’ll know that Express can handle server-side template engines. You can populate your HTML pages with various information and data directly onto your view. This allows us to generate HTML dynamically.
如果您过去使用过Express.js框架,那么您将知道Express可以处理服务器端模板引擎。 您可以将各种信息和数据直接填充到HTML页面上。 这使我们能够动态生成HTML。
In this article, we’ll introduce 3 popular template engines for Express: Pug, EJS and Mustache.
在本文中,我们将介绍3种用于Express的流行模板引擎:Pug,EJS和Mustache。
If you’d like to learn more about Express, follow this link.
如果您想了解有关Express的更多信息,请点击此链接 。
我应该使用哪些模板引擎? (What Template Engines Should I Use?)
There’s a wide variety of template engines that work with Express. The default template engine found in Express is Jade, which is now known as Pug. However, the default Jade installed in Express is still using the old version.
与Express一起使用的模板引擎种类繁多。 在Express中找到的默认模板引擎是Jade,现在称为Pug。 但是,Express中安装的默认Jade仍在使用旧版本。
In this breakdown, we’ll introduce the basic syntax and uses of Pug, EJS, and Mustache.
在此细分中,我们将介绍Pug,EJS和Mustache的基本语法和用法。
如何使用哈巴狗 (How To Use Pug)
To install Pug and use it in our Express app, we have to use npm
to install it first:
要安装Pug并在我们的Express应用中使用它,我们必须首先使用npm
进行安装: